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 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
andPUT
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 intoCode
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 aPOST
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
/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/