Просмотр исходного кода

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

Yohei-Shiina 3 лет назад
Родитель
Сommit
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;
     try {
       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) {
       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();
 
     // login