Skip to content

initial commit#320

Merged
yusuftomilola merged 4 commits intoDistinctCodes:mainfrom
shamoo53:Auth-Module
Oct 2, 2025
Merged

initial commit#320
yusuftomilola merged 4 commits intoDistinctCodes:mainfrom
shamoo53:Auth-Module

Conversation

@shamoo53
Copy link
Copy Markdown
Contributor

@shamoo53 shamoo53 commented Oct 2, 2025

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

@vercel
Copy link
Copy Markdown

vercel bot commented Oct 2, 2025

@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 yusuftomilola merged commit 933a565 into DistinctCodes:main Oct 2, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2. [BACKEND] Implement Auth Module (JWT)

2 participants