prevent re-verifying email
This commit is contained in:
parent
b89c0987c2
commit
6ff8eec722
@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user