Explorar o código

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

Yohei-Shiina %!s(int64=3) %!d(string=hai) anos
pai
achega
7753063b66
Modificáronse 1 ficheiros con 5 adicións e 4 borrados
  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