Skip to content

Commit da6af47

Browse files
authored
Merge pull request #7125 from Countly/anna/master
[SER-2766] Fixes issue in rights.js in exports.hasAdminAccess function to do not assume admin rights if no specific permission defined for user.
2 parents c62a60c + ec14eaf commit da6af47

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

api/utils/rights.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,15 +1155,25 @@ exports.hasAdminAccess = function(member, app_id, type) {
11551155
return true;
11561156
}
11571157

1158-
var isAdmin = true;
1158+
var isAdmin = false;
11591159
// check users who has permission property
11601160
if (hasPermissionObject) {
11611161
var types = type ? [type] : ["c", "r", "u", "d"];
1162+
var passesAllRules = true;
11621163
for (var i = 0; i < types.length; i++) {
1163-
if (member.permission[types[i]] && member.permission[types[i]][app_id] && !member.permission[types[i]][app_id].all) {
1164-
isAdmin = false;
1164+
if (member.permission[types[i]] && member.permission[types[i]][app_id]) {
1165+
if (!member.permission[types[i]][app_id].all) {
1166+
passesAllRules = false;
1167+
}
1168+
}
1169+
else {
1170+
passesAllRules = false;
11651171
}
11661172
}
1173+
if (passesAllRules) {
1174+
isAdmin = true;
1175+
}
1176+
11671177
}
11681178
// check legacy users who has admin_of property
11691179
// users should have at least one app in admin_of array

0 commit comments

Comments
 (0)