utsushiiro пре 7 година
родитељ
комит
e452100480
2 измењених фајлова са 16 додато и 13 уклоњено
  1. 16 1
      src/server/routes/admin.js
  2. 0 12
      src/server/service/passport.js

+ 16 - 1
src/server/routes/admin.js

@@ -1100,7 +1100,7 @@ module.exports = function(crowi, app) {
   actions.api.securityPassportSamlSetting = async(req, res) => {
   actions.api.securityPassportSamlSetting = async(req, res) => {
     const form = req.form.settingForm;
     const form = req.form.settingForm;
 
 
-    crowi.passportService.validateSamlSettingForm(req.form);
+    validateSamlSettingForm(req.form);
 
 
     if (!req.form.isValid) {
     if (!req.form.isValid) {
       return res.json({status: false, message: req.form.errors.join('\n')});
       return res.json({status: false, message: req.form.errors.join('\n')});
@@ -1478,6 +1478,21 @@ module.exports = function(crowi, app) {
     }, callback);
     }, callback);
   }
   }
 
 
+  /**
+   * validate setting form values for SAML
+   *
+   * This validation checks for the value of each mandatory items
+   * whether the value from the environment variables is empty and form value to update it is empty.
+   */
+  function validateSamlSettingForm(form) {
+    for (const key of crowi.passportService.mandatoryConfigKeysForSaml) {
+      const formValue = form.settingForm[key];
+      if (crowi.configManager.getConfigFromEnvVars('crowi', key) === null && formValue === '') {
+        form.errors.push(`${key} is required`);
+      }
+    }
+  }
+
   return actions;
   return actions;
 };
 };
 
 

+ 0 - 12
src/server/service/passport.js

@@ -492,18 +492,6 @@ class PassportService {
     return missingRequireds;
     return missingRequireds;
   }
   }
 
 
-  /**
-   * validate setting form values for SAML
-   */
-  validateSamlSettingForm(form) {
-    for (const key of this.mandatoryConfigKeysForSaml) {
-      const formValue = form.settingForm[key];
-      if (this.crowi.configManager.getConfigFromEnvVars('crowi', key) === null && formValue === '') {
-        form.errors.push(`${key} is required`);
-      }
-    }
-  }
-
   /**
   /**
    * setup serializer and deserializer
    * setup serializer and deserializer
    *
    *