From 7b2bc5c8441eafe641bf9dd677439763cee64ae2 Mon Sep 17 00:00:00 2001 From: "Aseem.70" Date: Thu, 22 Aug 2024 16:55:45 -0700 Subject: [PATCH] Restrict team joining until application submission and acceptance. --- app/server/controllers/UserController.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/server/controllers/UserController.js b/app/server/controllers/UserController.js index 6b66f5f32..18449820c 100644 --- a/app/server/controllers/UserController.js +++ b/app/server/controllers/UserController.js @@ -481,6 +481,11 @@ UserController.createOrJoinTeam = function(id, code, isCreate, callback) { User.find({}) .exec(function(err, users) { if (err) return callback(err); + const userWithProfile = users.find(user => user.id.toString() === id && user.status && user.status.admitted === true); + + if (!userWithProfile) { + return callback({ message: "You can only join or create a team once your profile is completed and you have been accepted." }); + } // Normalize all stored team codes for comparison const existingTeam = users.find(user => user.teamCode && user.teamCode.toLowerCase() === normalizedCode); @@ -508,7 +513,7 @@ UserController.createOrJoinTeam = function(id, code, isCreate, callback) { const teamMembers = users.filter(user => user.teamCode && user.teamCode.toLowerCase() === normalizedCode); if (existingTeam && teamMembers.length >= maxTeamSize) { - return callback({ message: "Team is full." }); + return callback({ message: `Team is full. The maximum number of team members allowed is ${maxTeamSize}.` }); } User.findOneAndUpdate(