Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat-Mutation for forgot password option #95 #371

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MuntazirHaider
Copy link

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

const client = new ApolloClient({
  uri: '<enter url here>',
  cache: new InMemoryCache(),
  headers: {
    otp: localStorage.getItem("otp") || ""
  }
});

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.

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.

1 participant