ソースを参照

move out error handling for externalAccount to be null of the try catch

Yohei-Shiina 3 年 前
コミット
7753063b66
1 ファイル変更5 行追加4 行削除
  1. 5 4
      packages/app/src/server/routes/login-passport.js

+ 5 - 4
packages/app/src/server/routes/login-passport.js

@@ -222,15 +222,16 @@ module.exports = function(crowi, app) {
     let externalAccount;
     let externalAccount;
     try {
     try {
       externalAccount = await getOrCreateUser(req, res, userInfo, providerId);
       externalAccount = await getOrCreateUser(req, res, userInfo, providerId);
-
-      if (externalAccount == null) { // just in case the returned value is null or undefined
-        throw Error('message.external_account_not_exist');
-      }
     }
     }
     catch (error) {
     catch (error) {
       return next(error);
       return next(error);
     }
     }
 
 
+    // just in case the returned value is null or undefined
+    if (externalAccount == null) {
+      return next(Error('message.external_account_not_exist'));
+    }
+
     const user = await externalAccount.getPopulatedUser();
     const user = await externalAccount.getPopulatedUser();
 
 
     // login
     // login