Beter group check and isAuthenticated()
This commit is contained in:
parent
794c885ac1
commit
6750c05f07
17
core/user.js
17
core/user.js
|
@ -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() {
|
||||||
|
|
Loading…
Reference in New Issue