Reset Password Flow
API Request
POST /api/resetPassword
Content-Type: application/json{
"token": "123456",
"password": "new password"
}API Response (Success)
HTTP/1.1 200 OK
Content-Type: application/json{
"success": true,
"status": 200,
"data": {
"message": "password reset Successfully !!"
}
}Sequence Diagram
Flow Description
- Request Initiation: Client sends POST request to
/api/resetPasswordwith reset token and new password. - CORS Validation: Validates origin and headers.
- Rate Limiting: Checks request frequency per client/IP.
- JWT Filter Bypass: Public endpoint, skips JWT validation.
- Controller Processing: Extracts token and new password.
- Service Layer: Validates token, hashes new password, updates user record.
- Response: Returns success or error message.
- JWT Filter Bypass: he JWT Request Filter recognizes /api/resetPassword as a public endpoint and skips token validation
- Controller Processing: Request flows to AuthController which extracts token and new password from request body
- Service Layer Processing: AuthController delegates to AuthService for business logic execution
- User Lookup: AuthService queries UserRepository to find user by username
- Token Validation: AuthService queries UserRepository to find user by reset token and check generation time must be within 2 minutes of current time, if fails returns 400 Bad Request with “Invalid or expired token”
- Database Update: Updates user password with hashed value
- Response: Returns 200 OK with message “Password reset successful”.
Last updated on