This is a full stack application built with a React frontend and a Node.js/Express backend. The application includes user authentication features such as signup, login, and OTP verification for secure actions.
Make sure you have the following software installed on your machine:
- Node.js (version >= 14.x)
- Yarn (version >= 1.x)
-
Clone the repository:
-
Install dependencies for both the frontend and backend.
To run the frontend:
-
Navigate to the ./client directory: cd client
-
Set the baseUrl in ./src/config/baseURL.js directory: change the value of baseUrl variable to api base url of backend
-
Install the dependencies: yarn
-
Start the development server: yarn dev
To run the backend
-
Navigate to ./server directory: cd ./server
-
Install the dependencies: yarn
-
Start the development server: yarn dev
Set up the following environment variables in your backend. Create a .env file in the ./server directory with the following content:
- PORT=your_port_number
- MONGO_URI=your_mongodb_connection_string
- JWT_SECRET=your_jwt_secret_key
- USER=your_email_service_user
- PASSWORD=your_email_service_password
** This password in env file can be generated by visiting manage your google account settings and searching for "app password". In other SMTP servers this will be different.
The backend authentication routes are:
- POST baseUrl/auth/signup - Route to sign up a new user.
- POST baseUrl/auth/verifyEmail - Route to verify a user's email with OTP.
- POST baseUrl/auth/login - Route to log in a user.
- POST baseUrl/auth/verifyLogin - Route to verify a user's action with OTP after login.
- POST baseUrl/auth/resendOtp/:id - Route to resend OTP.
- POST baseUrl/auth/logout - Route to log out a user.
- Signup: Users can sign up and will be asked to verify their email with an OTP.
- Login: Users can log in and will be asked to verify their actions with an OTP.
- Email Verification: After signing up, users must verify their email address using an OTP sent to their email.
- Edge Case Handling: Various edge cases are covered to ensure robust authentication flows.