瀏覽代碼

fix: use preferred_username as alternate for Azure AD

NGPixel 5 年之前
父節點
當前提交
692e5ca0bd
共有 1 個文件被更改,包括 2 次插入1 次删除
  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'