Beter group check and isAuthenticated()

This commit is contained in:
Bryan Ashby 2016-01-30 15:26:19 -07:00
parent 794c885ac1
commit 6750c05f07
1 changed files with 12 additions and 5 deletions

View File

@ -26,6 +26,10 @@ function User() {
this.properties = {}; // name:value this.properties = {}; // name:value
this.groups = []; // group membership(s) this.groups = []; // group membership(s)
this.isAuthenticated = function() {
return true === self.authenticated;
}
this.isValid = function() { this.isValid = function() {
if(self.userId <= 0 || self.username.length < Config.users.usernameMin) { if(self.userId <= 0 || self.username.length < Config.users.usernameMin) {
return false; return false;
@ -54,13 +58,16 @@ function User() {
groupNames = [ groupNames ]; groupNames = [ groupNames ];
} }
groupNames.forEach(function groupEntry(groupName) { var isMember = false;
if(-1 === self.groups.indexOf(groupName)) {
return false; _.forEach(groupNames, groupName => {
} if(-1 !== self.groups.indexOf(groupName)) {
isMember = true;
return false; // stop iteration
}
}); });
return true; return isMember;
}; };
this.getLegacySecurityLevel = function() { this.getLegacySecurityLevel = function() {