Browse Source

fix: use preferred_username as alternate for Azure AD

NGPixel 5 years ago
parent
commit
692e5ca0bd
1 changed files with 2 additions and 1 deletions
  1. 2 1
      server/modules/authentication/azure/authentication.js

+ 2 - 1
server/modules/authentication/azure/authentication.js

@@ -20,12 +20,13 @@ module.exports = {
         scope: ['profile', 'email', 'openid'],
         allowHttpForRedirectUrl: WIKI.IS_DEBUG
       }, async (iss, sub, profile, cb) => {
+        const usrEmail = _.get(profile, '_json.email', null) || _.get(profile, '_json.preferred_username')
         try {
           const user = await WIKI.models.users.processProfile({
             profile: {
               id: profile.oid,
               displayName: profile.displayName,
-              email: _.get(profile, '_json.email', ''),
+              email: usrEmail,
               picture: ''
             },
             providerKey: 'azure'