This project is a user authentication system built with React, Redux, and Node.js. It includes features for user registration, login, OTP (One-Time Password) handling, and JWT (JSON Web Token) authentication.
This project is a user authentication system built with React, Redux, and Node.js. It includes features for user registration, login, OTP (One-Time Password) handling, and JWT (JSON Web Token) authentication.
https://simplifii-guddu.netlify.app
Clone the Repository
git clone https://github.com/yourusername/login-flow.git
cd login-flow
Install Dependencies
npm install
Start the Development Server
npm start
https://simplifii-assinment-login-flow.onrender.com
This project is a Node.js application using Express for the backend with JWT authentication and OTP-based user registration. It also uses Nodemailer for sending OTPs via email.
.env
file.Install Dependencies
npm install
Configure Environment Variables
Create a .env
file in the root directory and add the following variables:
[email protected]
PASSWORD=your_email_password
JWT_SECRET=your_jwt_secret
PORT=8080
Start the Server
npm start
/user/register
POST
{
"email": "[email protected]",
"name": "User Name",
"mobile": "1234567890",
"isd": "+1",
"otp": "123456"
}
201 Created
: Successfully registered.404 Not Found
: User already registered.400 Bad Request
: Invalid OTP.500 Internal Server Error
: Server error./user/getotp
POST
{
"email": "[email protected]"
}
200 OK
: OTP sent successfully.409 Conflict
: Email already registered.500 Internal Server Error
: Server error./user/resendotp
POST
{
"email": "[email protected]"
}
200 OK
: OTP resent successfully.404 Not Found
: User not found.500 Internal Server Error
: Server error./user/login
POST
{
"email": "[email protected]",
"otp": "123456"
}
201 Created
: Login successful with JWT token.404 Not Found
: User not found.400 Bad Request
: Invalid OTP.403 Forbidden
: User is locked out.500 Internal Server Error
: Server error./user/singleuser
GET
token
: JWT token (required)200 OK
: User details retrieved successfully.403 Forbidden
: Unauthorized (Invalid token).404 Not Found
: User not found.401 Unauthorized
: Invalid token.Middleware/Authentication.Middleware.js
Middleware/LoginAttempt.Middleware.js
name
: User's name (required).email
: User's email (required, unique).mobile
: User's mobile number (required).isd
: International dialing code (required).otp
: OTP for verification (default: "1234").otpAttempts
: Number of OTP attempts (default: 0).lockoutUntil
: Date until which the user is locked out (default: null).Frontend:
Backend:
src/Routes/MainRoutes.js
Home Route
/
PrivateRoute
wrapped around Home
Register Route
/register
Signup
Login Route
/login
Login
src/Routes/PrivateRoute.js
src/Page/Signup/Signup.js
Form Fields:
Button States:
OTP Handling: Manages OTP request and submission with a timer for re-sending OTP.
Validation: Validates form inputs and OTP before submission.
src/Page/Home/Home.js
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to modify or add any specific details based on your actual project setup!