Better isGroupMember() impl.

This commit is contained in:
Bryan Ashby 2016-08-31 22:06:49 -06:00
parent e7ba6c406e
commit 2c53515b60
1 changed files with 7 additions and 15 deletions

View File

@ -60,28 +60,20 @@ function User() {
groupNames = [ groupNames ]; groupNames = [ groupNames ];
} }
// :TODO: _.some() const isMember = groupNames.some(gn => (-1 !== self.groups.indexOf(gn)));
var isMember = false;
_.forEach(groupNames, groupName => {
if(-1 !== self.groups.indexOf(groupName)) {
isMember = true;
return false; // stop iteration
}
});
return isMember; return isMember;
}; };
this.getLegacySecurityLevel = function() { this.getLegacySecurityLevel = function() {
if(self.isRoot() || self.isGroupMember('sysops')) { if(self.isRoot() || self.isGroupMember('sysops')) {
return 100; return 100;
} else if(self.isGroupMember('users')) {
return 30;
} else {
return 10; // :TODO: Is this what we want?
} }
if(self.isGroupMember('users')) {
return 30;
}
return 10; // :TODO: Is this what we want?
}; };
} }