Description
Explanation:
When a new user signups, the backend sends a verification link to the email with a token. The same token is stored in the created user's data in that database in order to verify it once the link is clicked. Immediately after the user signups, they are redirected to the verify your email page. Everything works correctly till now. but in case the user miss the first email, or they wish to receive new verification link, the button on that page creates a new request to the backend. The backend generates a new token and sends the verification link to the email but the problem is, the token is not updated in the database and it is considered as invalid token when it comes to the verification endpoint.
Possible Fix:
Modify the SendVerificationEmail.controller.js
to update the token after the email is sent.
Hint:
const updatedUser = await userModel.findOneAndUpdate({ email}, {mailedToken: newToken})