Reset Password
Authentication
Reset Password
Reset user password using OTP code
POST
Reset Password
Endpoint
http://localhost:3000/api/v1
This endpoint is public and does not require authentication.
Request Body
string
required
The email address associated with the account. Must match the email used in the forgot password
request.
string
required
The 6-digit OTP code sent to the email. Must be exactly 6 numeric digits.
string
required
The new password for the account. Minimum 6 characters.
Request Shape
Response
Success Response (200 OK)
boolean
Indicates if the password reset was successful.
object
Contains confirmation message.
string
Human-readable success message: “Password has been reset successfully”
What Happens on Password Reset
1
OTP Verification
System verifies the OTP code against the stored value in Redis.
2
Expiration Check
Ensures the OTP hasn’t expired (10-minute validity window).
3
Attempt Counter Check
Verifies that maximum attempts (3) haven’t been exceeded.
4
User Type Detection
System determines if the user is a Job Seeker or Company based on stored OTP data.
5
Password Hashing
New password is securely hashed using bcrypt algorithm.
6
Database Update
User’s password is updated in the database (JobSeeker or Company table).
7
Session Invalidation
All existing refresh tokens are invalidated, logging out all active sessions.
8
OTP Deletion
Used OTP is immediately deleted from Redis.
9
Success Response
Confirmation message is returned to the user.
Important: Session Invalidation
This security measure ensures that:- ✅ Any potentially compromised sessions are invalidated
- ✅ Only the user with the new password can access the account
- ✅ All devices are logged out for security
Error Responses
400 Bad Request - Validation Error
Returned when request validation fails.email must be an email- Invalid email formatcode must be exactly 6 characters long- Code is not 6 digitsnewPassword must be longer than or equal to 6 characters- Password too short
401 Unauthorized - Invalid or Expired Code
Returned when OTP is incorrect, expired, or doesn’t exist.- OTP code is incorrect
- OTP has expired (10 minutes validity)
- OTP was already used
- Email doesn’t match the email used in forgot password request
- OTP was never generated for this email
- Maximum verification attempts (3) exceeded
401 Unauthorized - User Not Found
Returned when no user exists with the provided email.500 Internal Server Error
Returned when an unexpected error occurs during password reset.Validation Rules
Password Requirements
Minimum Length: 6 characters
Strong Password Guidelines
A strong password should include:- ✅ At least 8 characters (minimum is 6)
- ✅ Mix of uppercase and lowercase letters
- ✅ At least one number
- ✅ At least one special character (@, #, $, %, etc.)
- ❌ Avoid common words or patterns
- ❌ Don’t reuse old passwords
OTP Behavior
OTP Validity: Each password reset code is valid for 10 minutes from generation. After
expiration, users need to request a new code via Forgot
Password.
After Password Reset
Once password is successfully reset:- ✅ All active sessions are logged out
- ✅ All refresh tokens are invalidated
- ✅ Password is securely updated in the database
- ✅ OTP code is deleted from Redis
- ✅ User must login again with the new password
Next Steps
After successful password reset:- Login using the Login endpoint with the new password
- Save credentials securely in your application
- Inform user that all other sessions have been logged out
Security Notes
Automatic User Type Detection: The system automatically determines whether the account is a
Job Seeker or Company account based on the OTP data. You don’t need to specify the user type.
Security Features
- Bcrypt Hashing - Passwords are hashed using bcrypt with salt rounds
- Session Invalidation - All existing sessions are terminated
- Single-Use OTP - Each code can only be used once successfully
- Time-Limited OTP - Codes expire after 10 minutes
- Attempt Limiting - Maximum 3 verification attempts per OTP
- Secure Storage - Passwords are never stored in plain text
Common Issues & Solutions
Related Endpoints
- Forgot Password - Request password reset code
- Login - Login with new password after reset
- Register Job Seeker - Create new job seeker account
- Register Company - Create new company account
