Skip to content

feat: implement AuthModule, JwtAuthGuard, RolesGuard, and email verification#665

Open
devbackend513-ux wants to merge 2 commits into
Nexacore-Org:mainfrom
devbackend513-ux:feat/auth-module-jwt-roles-email-verification
Open

feat: implement AuthModule, JwtAuthGuard, RolesGuard, and email verification#665
devbackend513-ux wants to merge 2 commits into
Nexacore-Org:mainfrom
devbackend513-ux:feat/auth-module-jwt-roles-email-verification

Conversation

@devbackend513-ux
Copy link
Copy Markdown

Summary

Implements all four authentication-related issues in a single PR.

Changes

AuthModule (#580)

  • POST /api/v1/auth/register — creates user, hashes password (bcrypt, 12 rounds), sends OTP email
  • POST /api/v1/auth/login — validates credentials, returns JWT + refresh token
  • POST /api/v1/auth/logout — revokes refresh token
  • POST /api/v1/auth/verify-email — validates OTP, marks email as verified
  • POST /api/v1/auth/resend-verification — rate-limited to 3 resends per hour

JwtAuthGuard (#581)

  • JwtAuthGuard using @nestjs/passport + passport-jwt registered as global APP_GUARD
  • @Public() decorator to opt out specific endpoints (register, login, resend, verify-email)
  • Expired/invalid tokens return 401 Unauthorized

RolesGuard (#582)

  • Role enum: USER, ADMIN, COMPLIANCE
  • @Roles() decorator + RolesGuard registered as global APP_GUARD (runs after JwtAuthGuard)
  • Role derived from JWT payload — not from request body
  • Non-matching roles return 403 Forbidden

Email Verification (#583)

  • OTP generated on registration, sent via MailService (nodemailer)
  • EmailVerifiedGuard blocks financial operations for unverified users
  • Resend rate-limited to 3 per hour per user

CI Workflow

  • Added .github/workflows/ci.yml with lint, build, and test steps

Testing

  • Build passes: npm run build
  • Tests pass: npm test

Closes #580
Closes #581
Closes #582
Closes #583

…ication

- Add AuthModule with register, login, logout, verify-email, resend-verification endpoints
- Implement JwtAuthGuard registered globally as APP_GUARD with @public() opt-out decorator
- Implement RolesGuard registered globally as APP_GUARD with @roles() decorator
- Add Role enum (USER, ADMIN, COMPLIANCE)
- Add EmailVerifiedGuard to block financial ops for unverified users
- Add User entity with role, email verification OTP, and refresh token fields
- Add MailService using nodemailer for OTP email delivery
- Add JwtStrategy (passport-jwt) for token validation
- Install @nestjs/passport, passport, passport-jwt, bcryptjs
- Add CI workflow (.github/workflows/ci.yml)

Closes Nexacore-Org#580
Closes Nexacore-Org#581
Closes Nexacore-Org#582
Closes Nexacore-Org#583
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@devbackend513-ux Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@portableDD
Copy link
Copy Markdown
Contributor

@devbackend513-ux please resolve conflicts

@devbackend513-ux
Copy link
Copy Markdown
Author

@portableDD conflict resolves

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment