feat: create confirm user page, option to resend email if link expires

This commit is contained in:
Aaron William Po
2023-05-29 15:51:59 -04:00
parent bc298bce0e
commit 06ae380b8f
9 changed files with 210 additions and 41 deletions

View File

@@ -21,16 +21,16 @@ const confirmUser = async (req: ConfirmUserRequest, res: NextApiResponse) => {
const { token } = req.query;
const user = req.user!;
const { id } = verifyConfirmationToken(token);
const { id } = await verifyConfirmationToken(token);
if (user.accountIsVerified) {
throw new ServerError('Your account is already verified.', 400);
}
if (user.id !== id) {
throw new ServerError('Could not confirm user.', 401);
}
if (user.accountIsVerified) {
throw new ServerError('User is already verified.', 400);
}
await updateUserToBeConfirmedById(id);
res.status(200).json({