prevent re-verifying email

This commit is contained in:
Puyodead1 2025-09-05 18:35:50 -04:00
parent b89c0987c2
commit 6ff8eec722
No known key found for this signature in database
GPG Key ID: A4FA4FEC0DD353FC

View File

@ -39,7 +39,7 @@ router.post(
async (req: Request, res: Response) => { async (req: Request, res: Response) => {
const user = await User.findOneOrFail({ const user = await User.findOneOrFail({
where: { id: req.user_id }, where: { id: req.user_id },
select: ["username", "email"], select: ["username", "email", "verified"],
}); });
if (!user.email) { if (!user.email) {
@ -47,6 +47,10 @@ router.post(
throw new HTTPError("User does not have an email address", 400); throw new HTTPError("User does not have an email address", 400);
} }
if (user.verified) {
throw new HTTPError("Email is already verified", 400);
}
await Email.sendVerifyEmail(user, user.email) await Email.sendVerifyEmail(user, user.email)
.then(() => { .then(() => {
return res.sendStatus(204); return res.sendStatus(204);