mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-04-05 18:09:04 +00:00
feat: create confirm user page, option to resend email if link expires
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user