From ffd193437e1285f7b04318dace01e342b208dca7 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Wed, 25 Sep 2024 15:14:22 +0800 Subject: [PATCH] add comments --- Client/src/Pages/Auth/Register/Register.jsx | 2 +- Server/controllers/authController.js | 1 + Server/db/mongo/modules/inviteModule.js | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/src/Pages/Auth/Register/Register.jsx b/Client/src/Pages/Auth/Register/Register.jsx index eb331304c..c9f61adae 100644 --- a/Client/src/Pages/Auth/Register/Register.jsx +++ b/Client/src/Pages/Auth/Register/Register.jsx @@ -596,7 +596,7 @@ const Register = ({ isSuperAdmin }) => { let registerForm = { ...form, role: isSuperAdmin ? ["superadmin"] : form.role, - inviteToken: token ? token : "", + inviteToken: token ? token : "", // Add the token to the request for verification }; let error = validateForm(registerForm, { context: { password: form.password }, diff --git a/Server/controllers/authController.js b/Server/controllers/authController.js index 6357d25de..4e589ac8a 100644 --- a/Server/controllers/authController.js +++ b/Server/controllers/authController.js @@ -52,6 +52,7 @@ const registerController = async (req, res, next) => { // Create a new user try { const { inviteToken } = req.body; + // If superAdmin exists, a token should be attached to all further register requests const superAdminExists = await req.db.checkSuperadmin(req, res); if (superAdminExists) { await req.db.getInviteTokenAndDelete(inviteToken); diff --git a/Server/db/mongo/modules/inviteModule.js b/Server/db/mongo/modules/inviteModule.js index 1b7d698cd..9a0d35621 100644 --- a/Server/db/mongo/modules/inviteModule.js +++ b/Server/db/mongo/modules/inviteModule.js @@ -42,7 +42,6 @@ const requestInviteToken = async (userData) => { * @throws {Error} If the invite token is not found or there is another error. */ const getInviteToken = async (token) => { - console.log(token); try { const invite = await InviteToken.findOne({ token,