AlgoListed
AlgoListed copied to clipboard
Implement Authentication throught out the website [ Bounty 10$ ]
• Implement a global authentication system. • After successful authentication, the user's data stored in localStorage should be pushed to the server. • Allow users to sync their local data to the server whenever they choose (e.g., through a "Sync" button or an automatic sync option after login).
Hi, I'll like to work on this issue
Added Authentication #284 i created a pull request regarding this issue
@Myestery @mYsTeRiOOOOOO Please share a proper proposal how you will implement it step by step thanks : )
@AayushSaini101 I have understood the architecture of the application what I can do here is: For credentials: Authentication Workflow Overview
### User Signup/Login:
- The frontend will collect user credentials and send them to the backend route /auth-service/signup.
- Signup route will verify the email, create the user and sign the jwt token with user data like email, userid etc and send the jwt as a the response object which will be stored in local storage.
- On login the frontend will send the login credentials to auth-service/login route. It will verify credentials, generate a JWT containing user data like email or userid role etc., and send it back to the frontend.
- The frontend will store the JWT in localStorage.
### Protected Routes:
- The frontend will send the JWT with every request to access protected pages.
- The backend will validate the JWT before providing access to protected APIs.
@Myestery @mYsTeRiOOOOOO Please share a proper proposal how you will implement it step by step thanks : )
Implemented authentication using Passport.js by setting up the Local Strategy for handling username and password authentication. Configured MongoDB with Mongoose to store user data and securely hashed passwords using Passport itself. Set up session management with express-session and integrated Passport middleware to handle authentication requests. Modified the user database, updated authentication routes, and set up registration and login routes, utilizing passport.authenticate() to validate user credentials and manage user sessions.