require invite token to register except for initial registration

This commit is contained in:
Alex Holliday committed 2024-09-25 15:12:07 +08:00
1 parent 4e8675df45
commit 5dbd8378e2
6 files changed
+42 -3

No files matched your search

+5
View File
@@ -51,6 +51,11 @@ const registerController = async (req, res, next) => {
}
// Create a new user
try {
const { inviteToken } = req.body;
const superAdminExists = await req.db.checkSuperadmin(req, res);
if (superAdminExists) {
await req.db.getInviteTokenAndDelete(inviteToken);
}
const newUser = await req.db.insertUser({ ...req.body }, req.file);
logger.info(successMessages.AUTH_CREATE_USER, {
service: SERVICE_NAME,