Skip to content

Comments

added forgot password#218

Merged
ahmadogo merged 3 commits intoMentoNest:mainfrom
Nabeelahh:feature/implement-forgot-password
Feb 23, 2026
Merged

added forgot password#218
ahmadogo merged 3 commits intoMentoNest:mainfrom
Nabeelahh:feature/implement-forgot-password

Conversation

@Nabeelahh
Copy link
Contributor

@Nabeelahh Nabeelahh commented Feb 22, 2026

closes #187 [

This PR implements a complete forgot password flow using OTP-based verification. It leverages the existing Mail Service to send 6-digit OTPs and adds secure password reset functionality with proper validation and expiration handling.

DTOs Added

  • ForgotPasswordDto - accepts user email
  • VerifyOtpDto - validates email + OTP combination
  • ResetPasswordDto - completes flow with new password

Service Layer Updates (auth.service.ts)

  • forgotPassword: Initiates flow by delegating to mailService.sendOtpEmail
  • verifyOtp: Validates OTP against repository/cache without exposing sensitive data
  • resetPassword:
    • Verifies OTP validity
    • Hashes new password using bcrypt
    • Updates user password
    • Invalidates used OTP (one-time use enforcement)

Security Features

  • OTP expires after 10 minutes (matches existing Mail Service TTL)
  • One-time use enforced - OTP invalidated after successful reset
  • No sensitive data exposed in error messages
  • Password properly hashed before storage

Added comprehensive unit tests:

  • OTP request delegates correctly to mail service
  • OTP verification (success, invalid OTP, expired scenarios)
  • ✅Password reset with hash verification and OTP invalidation

@Nabeelahh
Copy link
Contributor Author

Screenshot 2026-02-22 153604

@ahmadogo ahmadogo merged commit 9b1230b into MentoNest:main Feb 23, 2026
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 Forgot Password (Use Existing Mail & OTP Logic)

2 participants