Skip to content

Commit

Permalink
Use static nums for role elevation check (#1137)
Browse files Browse the repository at this point in the history
* I never have liked this test and mathematical calc... it's just asking for a security breach if there is an error somewhere else
* Set to static numbers... we have static numbers all over the place so continue to use these

Applies to #1109 and #1107

Auto-merge
  • Loading branch information
Martii authored May 17, 2017
1 parent 4143501 commit 1562c6f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions controllers/scriptStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ exports.storeScript = function (aUser, aMeta, aBuf, aCallback, aUpdate) {
}

// Check for role change and modify accordingly
if (aUser.role === userRoles.length - 1) {
if (aUser.role === 5) {
if (!aUser.save) {
// Probably using req.session.user which may have gotten serialized.
userDoc = aUser;
Expand All @@ -1352,7 +1352,7 @@ exports.storeScript = function (aUser, aMeta, aBuf, aCallback, aUpdate) {
return;
}

--aUser.role;
aUser.role = 4;
aUser.save(function (aErr, aUser) {
if (aErr) {
console.warn('MongoDB User save warning error\n' +
Expand All @@ -1365,7 +1365,7 @@ exports.storeScript = function (aUser, aMeta, aBuf, aCallback, aUpdate) {
});
});
} else {
--aUser.role;
aUser.role = 4;
aUser.save(function (aErr, aUser) {
if (aErr) {
console.warn('MongoDB User save warning error\n' +
Expand Down

0 comments on commit 1562c6f

Please sign in to comment.