✨ added guestsRequireInvite to config
This commit is contained in:
parent
6944c76b43
commit
732f88cbb2
@ -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 });
|
const user = await User.register({ ...body, req });
|
||||||
|
|
||||||
if (body.invite) {
|
if (body.invite) {
|
||||||
// await to fail if the invite doesn't exist (necessary for requireInvite to work properly) (username only signups are possible)
|
// 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);
|
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) });
|
return res.json({ token: await generateToken(user.id) });
|
||||||
|
@ -128,6 +128,7 @@ export interface ConfigValue {
|
|||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
requireCaptcha: boolean;
|
requireCaptcha: boolean;
|
||||||
requireInvite: boolean;
|
requireInvite: boolean;
|
||||||
|
guestsRequireInvite: boolean;
|
||||||
allowNewRegistration: boolean;
|
allowNewRegistration: boolean;
|
||||||
allowMultipleAccounts: boolean;
|
allowMultipleAccounts: boolean;
|
||||||
blockProxies: boolean;
|
blockProxies: boolean;
|
||||||
@ -277,6 +278,7 @@ export const DefaultConfigOptions: ConfigValue = {
|
|||||||
},
|
},
|
||||||
disabled: false,
|
disabled: false,
|
||||||
requireInvite: false,
|
requireInvite: false,
|
||||||
|
guestsRequireInvite: true,
|
||||||
requireCaptcha: true,
|
requireCaptcha: true,
|
||||||
allowNewRegistration: true,
|
allowNewRegistration: true,
|
||||||
allowMultipleAccounts: true,
|
allowMultipleAccounts: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user