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

refactor 'isTreatUsernameMatchingAsIdentical' to 'isSameUsernameTreatedAsIdenticalUser'

Yuki Takei 8 лет назад
Родитель
Сommit
47763f2f55

+ 1 - 1
lib/form/admin/securityPassportLdap.js

@@ -16,7 +16,7 @@ module.exports = form(
   field('settingForm[security:passport-ldap:bindDNPassword]'),
   field('settingForm[security:passport-ldap:searchFilter]'),
   field('settingForm[security:passport-ldap:attrMapUsername]'),
-  field('settingForm[security:passport-ldap:isTreatUsernameMatchingAsIdentical]').trim().toBooleanStrict(),
+  field('settingForm[security:passport-ldap:isSameUsernameTreatedAsIdenticalUser]').trim().toBooleanStrict(),
   field('settingForm[security:passport-ldap:groupSearchBase]'),
   field('settingForm[security:passport-ldap:groupSearchFilter]'),
   field('settingForm[security:passport-ldap:groupDnProperty]')

+ 3 - 3
lib/models/config.js

@@ -63,7 +63,7 @@ module.exports = function(crowi) {
       'security:passport-ldap:groupSearchBase' : undefined,
       'security:passport-ldap:groupSearchFilter' : undefined,
       'security:passport-ldap:groupDnProperty' : undefined,
-      'security:passport-ldap:isTreatUsernameMatchingAsIdentical': false,
+      'security:passport-ldap:isSameUsernameTreatedAsIdenticalUser': false,
 
       'aws:bucket'          : 'growi',
       'aws:region'          : 'ap-northeast-1',
@@ -278,9 +278,9 @@ module.exports = function(crowi) {
     return getValueForCrowiNS(config, key);
   };
 
-  configSchema.statics.isTreatUsernameMatchingAsIdentical = function(config)
+  configSchema.statics.isSameUsernameTreatedAsIdenticalUser = function(config, providerType)
   {
-    const key = 'security:passport-ldap:isTreatUsernameMatchingAsIdentical';
+    const key = `security:passport-${providerType}:isSameUsernameTreatedAsIdenticalUser`;
     return getValueForCrowiNS(config, key);
   };
 

+ 1 - 1
lib/models/external-account.js

@@ -84,7 +84,7 @@ class ExternalAccount {
           .then(user => {
             // when the User that have the same `username` exists
             if (user != null) {
-              throw new DuplicatedUsernameException(`User '${usernameToBeRegistered}' has already been existed`, user);
+              throw new DuplicatedUsernameException(`User '${usernameToBeRegistered}' already exists`, user);
             }
 
             // create a new User with STATUS_ACTIVE

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

@@ -115,8 +115,8 @@ module.exports = function(crowi, app) {
         .catch((err) => {
           if (err.name != null && err.name === 'DuplicatedUsernameException') {
             // get option
-            const isTreatUsernameMatchingAsIdentical = Config.isTreatUsernameMatchingAsIdentical(config);
-            if (isTreatUsernameMatchingAsIdentical) {
+            const isSameUsernameTreatedAsIdenticalUser = Config.isSameUsernameTreatedAsIdenticalUser(config, 'ldap');
+            if (isSameUsernameTreatedAsIdenticalUser) {
               // associate to existing user
               debug(`ExternalAccount '${ldapAccountId}' will be created and bound to the exisiting User account`);
               return ExternalAccount.associate('ldap', ldapAccountId, err.user);

+ 3 - 3
lib/views/admin/widget/passport/ldap.html

@@ -124,9 +124,9 @@
           </p>
 
           <div class="checkbox checkbox-info">
-            <input type="checkbox" id="cbTreatUsernameMatchingAsIdentical" name="settingForm[security:passport-ldap:isTreatUsernameMatchingAsIdentical]" value="1"
-                {% if settingForm['security:passport-ldap:isTreatUsernameMatchingAsIdentical'] %}checked{% endif %} />
-            <label for="cbTreatUsernameMatchingAsIdentical">
+            <input type="checkbox" id="cbSameUsernameTreatedAsIdenticalUser" name="settingForm[security:passport-ldap:isSameUsernameTreatedAsIdenticalUser]" value="1"
+                {% if settingForm['security:passport-ldap:isSameUsernameTreatedAsIdenticalUser'] %}checked{% endif %} />
+            <label for="cbSameUsernameTreatedAsIdenticalUser">
               {{ t("security_setting.Treat username matching as identical") }}
             </label>
           </div>