Feature/forgot and reset password flow #1551
Open
Ankit9997verma wants to merge 4 commits into
Open
Conversation
Owner
|
resolve conflicts |
Contributor
Author
|
hello @aryandas2911 , |
Contributor
Author
|
@aryandas2911 can you please review it . |
831606c to
4bd4d85
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Description
This PR implements the Forgot Password and Reset Password flows to allow users to securely recover their accounts.
On requesting a password reset, a secure, short-lived (1-hour expiry) token is generated on the backend and hashed via SHA-256 before database storage. The raw token is sent to the user's email via a custom Nodemailer SMTP transporter. The user can then navigate to the reset page using the emailed link, specify a new password that conforms to security criteria (8+ chars, uppercase, digit, special symbol), and submit it to reset their credentials.
🔗 Related Issue
Closes #1526
🛠 Changes Made
🖥️ Backend
backend/src/models/User.js):resetPasswordToken(String) andresetPasswordExpires(Date) schema fields to track password reset states.backend/routes/authRoutes.js):/api/auth/forgot-passwordand/api/auth/reset-password.backend/controllers/authController.js):forgotPassword:crypto.randomBytes(32)).resetPassword:backend/utils/mail.js):SMTP_HOST,SMTP_PORT,SMTP_SECURE,SMTP_USER, andSMTP_PASS).sendEmailwrapper method.backend/.env.example):🎨 Frontend
frontend/src/App.jsx):/forgot-passwordand/reset-passwordroutes under the public routes collection.<AnimatedRoutes />wrapper.frontend/src/pages/Login.jsx):/forgot-password.frontend/src/pages/ForgotPassword.jsx):frontend/src/pages/ResetPassword.jsx):/loginupon success.frontend/src/components/ScrollToTop.jsx):classNameattribute syntax warning.📸 Screenshots (if applicable)
✅ Checklist
🚀 Notes for Reviewers
.envto test email sending locally (a guide is provided in the updatedbackend/.env.example).