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

Implement forgot password flow #40

Merged
merged 3 commits into from
Dec 10, 2024
Merged

Implement forgot password flow #40

merged 3 commits into from
Dec 10, 2024

Conversation

johnny-t06
Copy link
Collaborator

Description

This is a branch off of #36 before some requested nit changes. Ideally we merge #36 into main, rebase this branch, and then merge. Still, we wanted to give some time to review this.

This is a dupe PR of #37 because of git issues.

In this PR, we created two new api routes /password and /verify-code.
/password has two methods: POST and PUT

  • POST is the initial forgot password request. In this we verify the user's email is a valid email and generate a random 4 digit code with an expiration time. This code and expiration time is stored into Code collection that relates to the User. We then send an email from our server + [email protected] with the 4 digit code to the user's email.
  • PUT is used to replace the user's password with the new password

/verify-code is another route with a POST method to verify the user's entered code against the code stored in our database. It returns success if the codes do match, error otherwise.

We also added some front end error messages for the forgot password flow.

Issues

Completes #29

Screenshots

Test

Reach out for the new .env or you won't be able to test

  1. You should create a new account because the DB has been wiped. Visit the root localhost and then sign in with the account [email protected], PW: 123456.
  2. Once you sign in, you will be directed to a mock sign up form. Fill that out with a valid email to receive reset-password emails.
  3. Visit the forgot password flow at /public/forgot-password and go through steps with your own email + account. Test edge cases in wrong email, code, etc..

Possible Downsides

N/A

Additional Documentations

https://www.nodemailer.com/smtp/oauth2/

wkim10
wkim10 previously approved these changes Dec 6, 2024
@wkim10 wkim10 dismissed their stale review December 6, 2024 20:49

dismiss

Copy link
Collaborator

@hanahkim1 hanahkim1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@wkim10 wkim10 merged commit 4411c67 into main Dec 10, 2024
1 check passed
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.

3 participants