Skip to content

Commit

Permalink
remove 400 errors for invalid team code
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronPersaud committed Oct 8, 2023
1 parent 1ac5462 commit 1782d74
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/controllers/userProfileController.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,6 @@ const userProfileController = function (UserProfile) {
return;
}

const teamcodeRegex = /^([a-zA-Z]-[a-zA-Z]{3}|[a-zA-Z]{5})$/;
if (!teamcodeRegex.test(req.body.teamCode)) {
res.status(400).send("The team code is invalid");
return;
};
record.teamCode = req.body.teamCode;

// find userData in cache
Expand Down Expand Up @@ -608,17 +603,12 @@ const userProfileController = function (UserProfile) {
if (key === "teamCode") {
const canEditTeamCode = req.body.requestor.role === "Owner" ||
req.body.requestor.permissions?.frontPermissions.includes("editTeamCode");
const teamcodeRegex = /^([a-zA-Z]-[a-zA-Z]{3}|[a-zA-Z]{5})$/;

if(!canEditTeamCode){
res.status(403).send("You are not authorized to edit team code.");
return;
}

if (!teamcodeRegex.test(value)) {
res.status(400).send("The team code is invalid");
return;
};
}

// remove user from cache, it should be loaded next time
Expand Down

0 comments on commit 1782d74

Please sign in to comment.