From 6750c05f07dc3c4ac6f1a5389033b0613411142a Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sat, 30 Jan 2016 15:26:19 -0700 Subject: [PATCH] Beter group check and isAuthenticated() --- core/user.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/core/user.js b/core/user.js index ffc0b140..0f92d81e 100644 --- a/core/user.js +++ b/core/user.js @@ -26,6 +26,10 @@ function User() { this.properties = {}; // name:value this.groups = []; // group membership(s) + this.isAuthenticated = function() { + return true === self.authenticated; + } + this.isValid = function() { if(self.userId <= 0 || self.username.length < Config.users.usernameMin) { return false; @@ -54,13 +58,16 @@ function User() { groupNames = [ groupNames ]; } - groupNames.forEach(function groupEntry(groupName) { - if(-1 === self.groups.indexOf(groupName)) { - return false; - } + var isMember = false; + + _.forEach(groupNames, groupName => { + if(-1 !== self.groups.indexOf(groupName)) { + isMember = true; + return false; // stop iteration + } }); - return true; + return isMember; }; this.getLegacySecurityLevel = function() {