Skip to content

Commit a2e8aea

Browse files
committed
Add demonstration gif
2 parents 3ba8f60 + 14613bc commit a2e8aea

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Secure auth with NodeJS
2+
> Login and registration system with TOTP (Time-based One-Time Password), password hashing using bcrypt, and some basic server-side validation.
3+
4+
## Features
5+
- Hash the password with bcrypt before saving it to the database.
6+
- Server-side checks: alphanumeric character validation for the username, minimum and maximum length checks for both password and username, check if the username is already registered, and a maximum attempt limit for entering the OTP code.
7+
- Handling of pending login requests awaiting OTP code verification, with expiration after 5 minutes.
8+
- Client-side QR code generation to easily add the secret key to your authentication app (e.g. Google Authenticator).
9+
- Simple use of JSON to send and receive requests, with realistic status codes for responses.
10+
- Use SQL parameters to prevent SQL injection.
11+
12+
## How to use
13+
### Install the dependencies
14+
```bash
15+
# Run the command inside the API/ folder
16+
npm install
17+
```
18+
### Start the backend server
19+
```bash
20+
# Run the command inside the API/ folder
21+
node server.js
22+
```
23+
> Make sure the HTML files are served from a server (hosted) and not opened directly as local files, because the login stores the pending login request ID in cookies, which won’t work if you open the file locally.
24+
25+
I hope this helps you learn how a robust login and signup system works. Have fun experimenting and modifying my code by adding extra features, for example, a token-based system after the user logs in.

0 commit comments

Comments
 (0)