summary refs log tree commit diff
path: root/api/src/routes/auth
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-09 13:23:36 +0200
committerGitHub <noreply@github.com>2021-10-09 13:23:36 +0200
commit89549712421b999d6cefd0a91602de9b6fdd26ff (patch)
tree73d86ef2d9b3454cca4ca92e1bd6e4481d96a21b /api/src/routes/auth
parent:bug: fix import (diff)
parent:art: do not auto guest register on login/register page (diff)
downloadserver-89549712421b999d6cefd0a91602de9b6fdd26ff.tar.xz
Merge pull request #428 from fosscord/dev
Various fixes and guest account enhancements
Diffstat (limited to 'api/src/routes/auth')
-rw-r--r--api/src/routes/auth/register.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/api/src/routes/auth/register.ts b/api/src/routes/auth/register.ts

index 9f3b46f1..4b08e78e 100644 --- a/api/src/routes/auth/register.ts +++ b/api/src/routes/auth/register.ts
@@ -154,16 +154,18 @@ router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Re }); } + if (!body.invite && (register.requireInvite || (register.guestsRequireInvite && !register.email))) { + // require invite to register -> e.g. for organizations to send invites to their employees + throw FieldErrors({ + email: { code: "INVITE_ONLY", message: req.t("auth:register.INVITE_ONLY") } + }); + } + const user = await User.register({ ...body, req }); if (body.invite) { // await to fail if the invite doesn't exist (necessary for requireInvite to work properly) (username only signups are possible) await Invite.joinGuild(user.id, body.invite); - } else if (register.requireInvite) { - // require invite to register -> e.g. for organizations to send invites to their employees - throw FieldErrors({ - email: { code: "INVITE_ONLY", message: req.t("auth:register.INVITE_ONLY") } - }); } return res.json({ token: await generateToken(user.id) });