feat: implement AuthModule, JwtAuthGuard, RolesGuard, and email verification#665
Open
devbackend513-ux wants to merge 2 commits into
Open
Conversation
…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
|
@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! 🚀 |
Contributor
|
@devbackend513-ux please resolve conflicts |
Author
|
@portableDD conflict resolves |
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.
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 emailPOST /api/v1/auth/login— validates credentials, returns JWT + refresh tokenPOST /api/v1/auth/logout— revokes refresh tokenPOST /api/v1/auth/verify-email— validates OTP, marks email as verifiedPOST /api/v1/auth/resend-verification— rate-limited to 3 resends per hourJwtAuthGuard (#581)
JwtAuthGuardusing@nestjs/passport+passport-jwtregistered as globalAPP_GUARD@Public()decorator to opt out specific endpoints (register, login, resend, verify-email)401 UnauthorizedRolesGuard (#582)
Roleenum:USER,ADMIN,COMPLIANCE@Roles()decorator +RolesGuardregistered as globalAPP_GUARD(runs after JwtAuthGuard)403 ForbiddenEmail Verification (#583)
MailService(nodemailer)EmailVerifiedGuardblocks financial operations for unverified usersCI Workflow
.github/workflows/ci.ymlwith lint, build, and test stepsTesting
npm run build✅npm test✅Closes #580
Closes #581
Closes #582
Closes #583