From 57309b433a4a589d82f26c955d4d2e6fdbc09379 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Mon, 29 Aug 2016 21:03:48 -0600 Subject: [PATCH] Misc & isRootUserId() --- core/user.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/core/user.js b/core/user.js index 7703f8fe..7446c872 100644 --- a/core/user.js +++ b/core/user.js @@ -18,6 +18,8 @@ exports.loadProperties = loadProperties; exports.getUserIdsWithProperty = getUserIdsWithProperty; exports.getUserList = getUserList; +exports.isRootUserId = function(id) { return 1 === id; }; + function User() { var self = this; @@ -28,7 +30,7 @@ function User() { this.isAuthenticated = function() { return true === self.authenticated; - } + }; this.isValid = function() { if(self.userId <= 0 || self.username.length < Config.users.usernameMin) { @@ -58,13 +60,15 @@ function User() { groupNames = [ groupNames ]; } + // :TODO: _.some() + var isMember = false; _.forEach(groupNames, groupName => { - if(-1 !== self.groups.indexOf(groupName)) { - isMember = true; - return false; // stop iteration - } + if(-1 !== self.groups.indexOf(groupName)) { + isMember = true; + return false; // stop iteration + } }); return isMember; @@ -103,9 +107,9 @@ User.prototype.load = function(userId, cb) { }; User.prototype.authenticate = function(username, password, cb) { - var self = this; + const self = this; - var cachedInfo = {}; + const cachedInfo = {}; async.waterfall( [ @@ -178,7 +182,7 @@ User.prototype.authenticate = function(username, password, cb) { self.authenticated = true; } - cb(err); + return cb(err); } ); };