Skip to content

Implement-Token-Refresh-Endpoin#43

Merged
ayshadogo merged 1 commit intoDfunder:mainfrom
shamoo53:Implement-Token-Refresh-Endpoint
Mar 6, 2026
Merged

Implement-Token-Refresh-Endpoin#43
ayshadogo merged 1 commit intoDfunder:mainfrom
shamoo53:Implement-Token-Refresh-Endpoint

Conversation

@shamoo53
Copy link
Contributor

@shamoo53 shamoo53 commented Mar 6, 2026

I have successfully implemented the token refresh endpoint with all required functionality:

✅ Implementation Complete
Endpoint Created: POST /api/auth/refresh-token

Key Features Implemented:

Token Validation: Verifies JWT signature and token type
Hash Comparison: Compares provided refresh token against stored SHA-256 hash
403 Error Handling: Returns 403 for invalid/expired tokens or hash mismatches
New Access Token: Issues fresh JWT access token with user data
Refresh Token Rotation: Generates new refresh token and updates stored hash
Old Token Invalidation: Previous refresh token becomes invalid after successful refresh
Files Modified:

src/controllers/auth.controller.js - Added refreshToken function
src/routes/auth.routes.js - Added refresh token route
src/validators/auth.validators.js - Added refresh token schema validation
src/tests/auth.refresh-token.test.js - Comprehensive test suite
Test Coverage: 7 test cases covering all scenarios including valid refresh, invalid tokens, expired tokens, hash mismatches, and malformed JWTs.

The implementation follows the existing codebase patterns and maintains security best practices with proper token rotation and hash verification.
Closes #23

Implement-Token-Refresh-Endpoin
@ayshadogo ayshadogo merged commit 80ec259 into Dfunder:main Mar 6, 2026
3 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.

Implement Token Refresh Endpoint

2 participants