Skip to main content
POST
Reset Password

Endpoint

Base URL: 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

All Sessions Logged Out: After a successful password reset, all active sessions are automatically terminated. The user must login again with the new password.
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.
Common validation errors:
  • email must be an email - Invalid email format
  • code must be exactly 6 characters long - Code is not 6 digits
  • newPassword 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.
Possible causes:
  • 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.
This can occur if the account was deleted between the forgot password and reset password requests.

500 Internal Server Error

Returned when an unexpected error occurs during password reset.

Validation Rules

Password Requirements

Minimum Length: 6 characters
Recommended: Use at least 8 characters with a mix of uppercase, lowercase, numbers, and special characters for better security.

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.
Maximum Attempts: Each OTP can be verified a maximum of 3 times. After 3 failed attempts, the code is invalidated and a new request is required.
Single Use: Once the password is successfully reset, the OTP is immediately deleted and cannot be reused.

After Password Reset

Once password is successfully reset:
  1. ✅ All active sessions are logged out
  2. ✅ All refresh tokens are invalidated
  3. ✅ Password is securely updated in the database
  4. ✅ OTP code is deleted from Redis
  5. ✅ User must login again with the new password

Next Steps

After successful password reset:
  1. Login using the Login endpoint with the new password
  2. Save credentials securely in your application
  3. 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.
Case Sensitive Password: Unlike email, the password is case-sensitive. Make sure users enter it exactly as intended.

Security Features

  1. Bcrypt Hashing - Passwords are hashed using bcrypt with salt rounds
  2. Session Invalidation - All existing sessions are terminated
  3. Single-Use OTP - Each code can only be used once successfully
  4. Time-Limited OTP - Codes expire after 10 minutes
  5. Attempt Limiting - Maximum 3 verification attempts per OTP
  6. Secure Storage - Passwords are never stored in plain text

Common Issues & Solutions