sou 7 лет назад
Родитель
Сommit
9e19f71960
2 измененных файлов с 7 добавлено и 7 удалено
  1. 4 4
      lib/routes/login-passport.js
  2. 3 3
      lib/views/login.html

+ 4 - 4
lib/routes/login-passport.js

@@ -97,7 +97,7 @@ module.exports = function(crowi, app) {
       'name': nameToBeRegistered
     }
 
-    const externalAccount = await getOrCreateUser(req, next, userInfo, provider);
+    const externalAccount = await getOrCreateUser(req, res, next, userInfo, provider);
     const user = await externalAccount.getPopulatedUser();
 
     // login
@@ -214,7 +214,7 @@ module.exports = function(crowi, app) {
       'username': response.displayName,
       'name': `${response.name.givenName} ${response.name.familyName}`
     }
-    const externalAccount = await getOrCreateUser(req, next, userInfo, provider);
+    const externalAccount = await getOrCreateUser(req, res, next, userInfo, provider);
     const user = await externalAccount.getPopulatedUser();
 
     // login
@@ -260,7 +260,7 @@ module.exports = function(crowi, app) {
     });
   };
 
-  const getOrCreateUser = async(req, next, userInfo, provider) => {
+  const getOrCreateUser = async(req, res, next, userInfo, provider) => {
     try {
       // find or register(create) user
       const externalAccount = await ExternalAccount.findOrRegister(
@@ -282,7 +282,7 @@ module.exports = function(crowi, app) {
         }
         else {
           req.flash('provider-DuplicatedUsernameException', provider);
-          return next();
+          return loginFailure(req, res, next);
         }
       }
       throw err;  // throw again

+ 3 - 3
lib/views/login.html

@@ -42,12 +42,12 @@
         # The case that there already exists a user whose username matches ID of the newly created LDAP user
         # https://github.com/weseek/growi/issues/193
         #}
-        {% set isDuplicatedUsernameExceptionOccured = req.flash('isDuplicatedUsernameExceptionOccured') %}
-        {% if isDuplicatedUsernameExceptionOccured != null %}
+        {% set failedProvider = req.flash('provider-DuplicatedUsernameException') %}
+        {% if failedProvider != null %}
         <div class="alert alert-warning small">
           <p><strong><i class="icon-fw icon-ban"></i>DuplicatedUsernameException occured</strong></p>
           <p>
-            Your LDAP authentication was succeess, but a new user could not be created.
+            Your {{ failedProvider }} authentication was succeess, but a new user could not be created.
             See the issue <a href="https://github.com/weseek/growi/issues/193">#193</a>.
           </p>
         </div>