From 0c6472ab85d80e12b837516011d583849709bede Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 20 Jul 2019 11:09:55 -0400 Subject: [PATCH] feat: azure ad auth --- .../authentication/azure/authentication.js | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/server/modules/authentication/azure/authentication.js b/server/modules/authentication/azure/authentication.js index 45d165c6..60898779 100644 --- a/server/modules/authentication/azure/authentication.js +++ b/server/modules/authentication/azure/authentication.js @@ -1,3 +1,5 @@ +const _ = require('lodash') + /* global WIKI */ // ------------------------------------ @@ -17,14 +19,22 @@ module.exports = { responseMode: 'form_post', scope: ['profile', 'email', 'openid'], allowHttpForRedirectUrl: WIKI.IS_DEBUG - }, (iss, sub, profile, cb) => { - console.info(iss, sub, profile) - // WIKI.models.users.processProfile(waadProfile).then((user) => { - // return cb(null, user) || true - // }).catch((err) => { - // return cb(err, null) || true - // }) - } - )) + }, async (iss, sub, profile, cb) => { + try { + const user = await WIKI.models.users.processProfile({ + profile: { + id: profile.oid, + displayName: profile.displayName, + email: _.get(profile, '_json.email', ''), + picture: '' + }, + providerKey: 'azure' + }) + cb(null, user) + } catch (err) { + cb(err, null) + } + }) + ) } }