Skip to content

Feat/128 jwt auth module#181

Merged
Olowodarey merged 2 commits intoDevsol-01:mainfrom
jahrulezfrancis:feat/128-jwt-auth-module
Feb 23, 2026
Merged

Feat/128 jwt auth module#181
Olowodarey merged 2 commits intoDevsol-01:mainfrom
jahrulezfrancis:feat/128-jwt-auth-module

Conversation

@jahrulezfrancis
Copy link
Copy Markdown
Contributor

Description

This PR implements a stateless authentication system using JSON Web Tokens (JWT). It provides a secure way to handle user registration, login, and session management, fully integrated with the existing Prisma-backed UserModule.

Key Changes

  • Auth Core:
    • Implemented AuthService for password hashing (bcrypt), token generation, and credential validation.
    • Created AuthController exposing public registration and login endpoints.
  • User Integration:
    • Extended UserService with create() and findByEmail() methods for database synchronization.
    • Fully integrated auth logic with the Prisma client.
  • Stateless Security:
    • Configured JwtStrategy to extract and validate bearer tokens from requests.
    • Created a custom @CurrentUser() decorator to streamline access to authenticated user data within protected controllers.
  • Documentation:
    • Updated .env.example with required JWT and Webhook configuration keys.

Acceptance Criteria Checklist

  • Installed and configured @nestjs/jwt and @nestjs/passport.
  • Created AuthModule, AuthService, and AuthController.
  • Implemented /auth/login and /auth/register endpoints.
  • Created JwtStrategy for token validation and payload extraction.
  • Created custom @CurrentUser() decorator for request object integration.

Testing Results

Unit Tests

Verified core logic in auth.service.spec.ts:

  • Successful user registration and hashing.
  • Conflict handling for existing emails.
  • Login validation for valid/invalid credentials.

E2E Tests

Verified full lifecycle in auth.e2e-spec.ts:

  • Registration flow and response structure.
  • Login flow and token issuance.
  • Protected route access (verified via /users/me) using the @CurrentUser decorator.

This PR closes #128

Setup Instructions

Ensure the following variables are set in your .env file:

  • JWT_SECRET: A secure key for signing tokens.
  • JWT_EXPIRATION: Token lifespan (e.g., 1h).

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 23, 2026

@jahrulezfrancis is attempting to deploy a commit to the devsol-01's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Olowodarey Olowodarey merged commit 561ecc9 into Devsol-01:main Feb 23, 2026
1 check failed
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.

Implement JWT Authentication Module

2 participants