AlgoListed icon indicating copy to clipboard operation
AlgoListed copied to clipboard

Implement Authentication throught out the website [ Bounty 10$ ]

Open AayushSaini101 opened this issue 1 year ago • 6 comments

•⁠ ⁠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).

AayushSaini101 avatar Oct 19 '24 06:10 AayushSaini101

Hi, I'll like to work on this issue

Myestery avatar Oct 19 '24 06:10 Myestery

Added Authentication #284 i created a pull request regarding this issue

mYsTeRiOOOOOO avatar Oct 19 '24 14:10 mYsTeRiOOOOOO

@Myestery @mYsTeRiOOOOOO Please share a proper proposal how you will implement it step by step thanks : )

AayushSaini101 avatar Oct 20 '24 16:10 AayushSaini101

@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.

mohdjami avatar Oct 20 '24 18:10 mohdjami

@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.

mYsTeRiOOOOOO avatar Oct 21 '24 14:10 mYsTeRiOOOOOO