From 3cb5cbd8d539a2d57d30b988e60f01f5bf4c124e Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 23 Jan 2018 23:08:11 +0000 Subject: [PATCH] Allow adminAuth.user to be a Function Fixes #1461 --- red/api/auth/clients.js | 6 +-- red/api/auth/index.js | 115 +++++++++++++++++++++------------------- red/api/auth/tokens.js | 8 ++- red/api/auth/users.js | 59 +++++++++++---------- 4 files changed, 97 insertions(+), 91 deletions(-) diff --git a/red/api/auth/clients.js b/red/api/auth/clients.js index 4495efba0..63e59ccce 100644 --- a/red/api/auth/clients.js +++ b/red/api/auth/clients.js @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ - -var when = require("when"); var clients = [ {id:"node-red-editor",secret:"not_available"}, @@ -25,9 +23,9 @@ module.exports = { get: function(id) { for (var i=0;i 0) { - user.image = arguments[0].photos[0].value; + } else { + // Try to extract common profile information + if (args[0].hasOwnProperty('photos') && args[0].photos.length > 0) { + user.image = args[0].photos[0].value; + } + return cleanUser(user); } - return when.resolve(user); } - } - return when.resolve(null); + return null; + }); } function get(username) { - return when.resolve(users[username]); + return Promise.resolve(users[username]); } function getDefaultUser() { - return when.resolve(null); + return Promise.resolve(null); } var api = { @@ -63,7 +64,6 @@ var api = { function init(config) { users = {}; - passwords = {}; defaultUser = null; if (config.type == "credentials" || config.type == "strategy") { if (config.users) { @@ -77,11 +77,7 @@ function init(config) { } for (var i=0;i