Skip to content

feat(auth): add forgot password and reset password flow#248

Open
devprashant19 wants to merge 1 commit into
Userunknown84:mainfrom
devprashant19:fix/password-reset
Open

feat(auth): add forgot password and reset password flow#248
devprashant19 wants to merge 1 commit into
Userunknown84:mainfrom
devprashant19:fix/password-reset

Conversation

@devprashant19

Copy link
Copy Markdown
Contributor

Description

This PR introduces a comprehensive "Forgot Password" flow to prevent users who register with an email and password from being permanently locked out if they forget their credentials.

Changes

  • backend/controllers/authController.js:
    • Implemented forgotPassword which generates a time-limited (15-minute) stateless JWT. The token is dynamically signed using the user's current password hash (process.env.JWT_SECRET + user.password), meaning it mathematically auto-invalidates the moment the password is changed.
    • Implemented resetPassword which decodes and validates the token before updating the user's password.
    • Integrated nodemailer to dispatch the reset links to the user's email.
  • backend/routes/authRoutes.js: Exposed the /forgot-password and /reset-password POST endpoints with appropriate express-validator security rules.
  • backend/package.json: Added nodemailer to dependencies.

Related Issues

Type of Change

  • Security fix
  • Bug fix
  • New feature
  • Refactoring

Pre-submission Checklist

  • Verified stateless JWT auto-invalidates after password mutation to prevent replay attacks.
  • Verified fallback behavior gracefully logs the reset link when SMTP credentials aren't provided.

@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

@devprashant19 is attempting to deploy a commit to the Aditya Sharma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Userunknown84

Copy link
Copy Markdown
Owner

auth flow is ok but in frontend can this task perform as there is no frontend changes doing here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No Password Reset Functionality

2 participants