Merged
Conversation
|
@shamoo53 is attempting to deploy a commit to the naijabuz's projects Team on Vercel. A member of the Team first needs to authorize it. |
yusuftomilola
approved these changes
Oct 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description: Implement Authentication Module with JWT & Refresh Tokens
📌 Context
The application currently lacks a secure authentication mechanism. To support user sessions and protect routes, we need an authentication module that leverages JWT for access tokens and refresh tokens for session persistence. This will enable secure login, route protection, and token lifecycle management.
🎯 Goal
Implement an AuthModule that provides:
Secure login with email + password.
Issuance of accessToken + refreshToken.
Middleware/guards for protecting routes with JWT strategy.
Refresh mechanism for session persistence.
Password hashing with bcrypt to store credentials securely.
✅ Tasks & Implementation
Auth Module Setup
Generate auth.module.ts, auth.service.ts, and auth.controller.ts.
Register JwtModule with secrets & expiration configs (from .env).
User Login Flow
Validate email + password against database.
Hash passwords with bcrypt on registration.
On successful login, return { accessToken, refreshToken }.
JWT Strategy & Guards
Create JwtStrategy for validating tokens.
Implement JwtAuthGuard to protect routes.
Refresh Tokens
Create /auth/refresh endpoint.
Validate refresh token & issue new access token.
Ensure refresh tokens have longer expiration.
Token Expiration
Access Token: ~15 minutes.
Refresh Token: ~7 days.
Store refresh tokens in DB (or memory) with user binding.
Security Hardening
Store secrets in .env (e.g., JWT_ACCESS_SECRET, JWT_REFRESH_SECRET).
Use bcrypt with salt rounds (e.g., bcrypt.hash(password, 10)).
Close #240