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

WIP: impl /me/external-account/associate

Yuki Takei 8 лет назад
Родитель
Сommit
be9498d462
3 измененных файлов с 12 добавлено и 29 удалено
  1. 9 13
      lib/routes/me.js
  2. 3 0
      lib/service/passport.js
  3. 0 16
      lib/views/me/external-accounts.html

+ 9 - 13
lib/routes/me.js

@@ -183,15 +183,16 @@ module.exports = function(crowi, app) {
 
     if (!passportService.isLdapStrategySetup) {
       debug('LdapStrategy has not been set up');
-      return next();
+      req.flash('warningMessage', 'LdapStrategy has not been set up');
+      return res.redirect('/me/external-accounts');
     }
 
     const loginForm = req.body.loginForm;
 
     if (!req.form.isValid) {
-      debug("invalid form");
-      return res.render('login', {
-      });
+      debug('invalid form');
+      req.flash('warningMessage', 'invalid form');
+      return res.redirect('/me/external-accounts');
     }
 
     console.log(loginForm);
@@ -205,18 +206,13 @@ module.exports = function(crowi, app) {
         console.log('LDAP Server Error: ', err);
         req.flash('warningMessage', 'LDAP Server Error occured.');
       }
-      if (info) {
-        if (info.name != null && info.name === 'DuplicatedUsernameException') {
-          req.flash('isDuplicatedUsernameExceptionOccured', true);
-        }
-      }
-      if (!user) {
-        req.flash('errorMessage', 'Not found.');
+      if (info && info.message) {
+        req.flash('warningMessage', info.message);
       }
-      else {
+      if (user) {
         req.flash('successMessage', 'Successfully added.');
       }
-    })(req, res, () => { res.redirect('/me/external-accounts'); });
+    })(req, res, () => {res.redirect('/me/external-accounts')});
   }
 
   actions.externalAccounts.disassociate = function(req, res) {

+ 3 - 0
lib/service/passport.js

@@ -119,6 +119,9 @@ class PassportService {
       (req, ldapAccountInfo, done) => {
         debug("LDAP authentication has succeeded", ldapAccountInfo);
 
+        // TODO impl test mode
+
+
         const ExternalAccount = this.crowi.model('ExternalAccount');
 
         // it is guaranteed that username that is input from form can be acquired

+ 0 - 16
lib/views/me/external-accounts.html

@@ -22,22 +22,6 @@
 
   <div class="tab-content">
 
-  {#
-    # The case that there already exists a user whose username matches ID of the newly created LDAP user
-    # https://github.com/weseek/crowi-plus/issues/193
-    #}
-  {% set isDuplicatedUsernameExceptionOccured = req.flash('isDuplicatedUsernameExceptionOccured') %}
-  {% if isDuplicatedUsernameExceptionOccured != null %}
-  <div class="alert alert-warning">
-    <i class="fa fa-fw fa-info-circle"></i>
-    <strong>DuplicatedUsernameException occured</strong>
-    <p>
-      Your LDAP authentication was succeess, but a new user could not be created.
-      See the issue <a href="https://github.com/weseek/crowi-plus/issues/193">#193</a>.
-    </p>
-  </div>
-  {% endif %}
-
   {% set error = req.flash('errorMessage') %}
   {% if error.length %}
   {% for e in error %}