Feat-Mutation for forgot password option #95 #371
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.
I did the following changes to implement the forgot password feature -:
1. Schema
a. requestPasswordReset - take email and give message, success, and encrypted otp in response.
b. verifyPasswordResetOtp - take otp from user and give message and success in response.
c. resetPassword - take email and new password and give message, success in response.
2.Resolver
a. requestPasswordReset - send otp to email and give encrypted otp
b. verifyPasswordResetOtp - compare given otp and encrypted otp and verify user
c. resetPassword - update the user password
To use this feature, some things to do in frontend -:
1. Store the email and encrypted otp in local storage for limited time (e.g - 2min)
2. Extract otp from local storage and set it in header using apollo client here's how you can do this
In index.js file add this code
3. Extract email from local storage and take new password from user and give it to resetPassword
I use nodemailer and otp-generator npm packages.
User dont need to be Authorized in order to forgot his password.