diff options
author | Puyodead1 <puyodead@protonmail.com> | 2023-02-24 06:36:57 -0500 |
---|---|---|
committer | Puyodead1 <puyodead@protonmail.com> | 2023-02-24 06:36:57 -0500 |
commit | ed38d74b3e994f4bd7be5ac22fb167f4169c77a3 (patch) | |
tree | 27edc1392e7e4bc18fc02f57e5a8ae7e58ac5bc1 | |
parent | implement password reset (diff) | |
download | server-ed38d74b3e994f4bd7be5ac22fb167f4169c77a3.tar.xz |
don't return token on register if verification required
-rw-r--r-- | src/api/routes/auth/register.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/api/routes/auth/register.ts b/src/api/routes/auth/register.ts index 0bf8efae..c941fdf6 100644 --- a/src/api/routes/auth/register.ts +++ b/src/api/routes/auth/register.ts @@ -278,6 +278,17 @@ router.post( await Invite.joinGuild(user.id, body.invite); } + // return an error for unverified accounts if verification is required + if (Config.get().login.requireVerification && !user.verified) { + throw FieldErrors({ + login: { + code: "ACCOUNT_LOGIN_VERIFICATION_EMAIL", + message: + "Email verification is required, please check your email.", + }, + }); + } + return res.json({ token: await generateToken(user.id) }); }, ); |