-
Notifications
You must be signed in to change notification settings - Fork 134
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
Location: backend/src/auth/helper/jwt-helper.ts
Description
The 2FA login flow requires a short-lived "pending" JWT that is issued after a user passes the password check but before they complete the second factor. This token proves the user entered the correct password without granting full access. It must expire quickly (5 minutes) and carry a type claim of "2fa_pending" so it cannot be reused as a real access token.
The JwtHelper class already exists in the codebase and handles token generation and refresh — this issue extends it with two new methods needed specifically for the 2FA flow.
Acceptance Criteria
- A
generateTempToken(userId: string): stringmethod is added toJwtHelperthat:- Signs a payload of
{ sub: userId, type: '2fa_pending' }using the existing JWT secret - Sets expiry to
'5m' - Returns the signed token string
- Signs a payload of
- A
verifyWithSecret(token: string): JwtPayloadmethod is added toJwtHelperthat:- Wraps
jwtService.verify()with the application JWT secret - Throws
UnauthorizedExceptionwith message"Invalid or expired token"if verification fails - Returns the decoded payload
- Wraps
- Both methods follow the existing code style and error handling patterns in
JwtHelper -
npx tsc --noEmitpasses with no errors
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers