itizawa 6 лет назад
Родитель
Сommit
33930f7b19
1 измененных файлов с 48 добавлено и 11 удалено
  1. 48 11
      src/client/js/services/AdminLdapSecurityContainer.js

+ 48 - 11
src/client/js/services/AdminLdapSecurityContainer.js

@@ -40,17 +40,17 @@ export default class AdminLdapSecurityContainer extends Container {
     const response = await this.appContainer.apiv3.get('/security-setting/');
     const { ldapAuth } = response.data.securityParams;
     this.setState({
-      isUserBind: ldapAuth.isUserBind,
-      ldapBindDN: ldapAuth.ldapBindDN,
-      ldapBindDNPassword: ldapAuth.ldapBindDNPassword,
-      ldapSearchFilter: ldapAuth.ldapSearchFilter,
-      ldapAttrMapUsername: ldapAuth.ldapAttrMapUsername,
-      isSameUsernameTreatedAsIdenticalUser: ldapAuth.isSameUsernameTreatedAsIdenticalUser,
-      ldapAttrMapMail: ldapAuth.ldapAttrMapMail,
-      ldapAttrMapName: ldapAuth.ldapAttrMapName,
-      ldapGroupSearchBase: ldapAuth.ldapGroupSearchBase,
-      ldapGroupSearchFilter: ldapAuth.ldapGroupSearchFilter,
-      ldapGroupDnProperty: ldapAuth.ldapGroupDnProperty,
+      isUserBind: ldapAuth.isUserBind || false,
+      ldapBindDN: ldapAuth.ldapBindDN || '',
+      ldapBindDNPassword: ldapAuth.ldapBindDNPassword || '',
+      ldapSearchFilter: ldapAuth.ldapSearchFilter || '',
+      ldapAttrMapUsername: ldapAuth.ldapAttrMapUsername || '',
+      isSameUsernameTreatedAsIdenticalUser: ldapAuth.isSameUsernameTreatedAsIdenticalUser || false,
+      ldapAttrMapMail: ldapAuth.ldapAttrMapMail || '',
+      ldapAttrMapName: ldapAuth.ldapAttrMapName || '',
+      ldapGroupSearchBase: ldapAuth.ldapGroupSearchBase || '',
+      ldapGroupSearchFilter: ldapAuth.ldapGroupSearchFilter || '',
+      ldapGroupDnProperty: ldapAuth.ldapGroupDnProperty || '',
     });
   }
 
@@ -146,4 +146,41 @@ export default class AdminLdapSecurityContainer extends Container {
     this.setState({ groupDnProperty: inputValue });
   }
 
+  /**
+   * Update ldap option
+   */
+  async updateLdapSetting() {
+
+    const response = await this.appContainer.apiv3.put('/security-setting/ldap', {
+      isUserBind: this.state.isUserBind,
+      ldapBindDN: this.state.ldapBindDN,
+      ldapBindDNPassword: this.state.ldapBindDNPassword,
+      ldapSearchFilter: this.state.ldapSearchFilter,
+      ldapAttrMapUsername: this.state.ldapAttrMapUsername,
+      isSameUsernameTreatedAsIdenticalUser: this.state.isSameUsernameTreatedAsIdenticalUser,
+      ldapAttrMapMail: this.state.ldapAttrMapMail,
+      ldapAttrMapName: this.state.ldapAttrMapName,
+      ldapGroupSearchBase: this.state.ldapGroupSearchBase,
+      ldapGroupSearchFilter: this.state.ldapGroupSearchFilter,
+      ldapGroupDnProperty: this.state.ldapGroupDnProperty,
+    });
+
+    const { securitySettingParams } = response.data;
+
+    this.setState({
+      isUserBind: securitySettingParams.isUserBind || false,
+      ldapBindDN: securitySettingParams.ldapBindDN || '',
+      ldapBindDNPassword: securitySettingParams.ldapBindDNPassword || '',
+      ldapSearchFilter: securitySettingParams.ldapSearchFilter || '',
+      ldapAttrMapUsername: securitySettingParams.ldapAttrMapUsername || '',
+      isSameUsernameTreatedAsIdenticalUser: securitySettingParams.isSameUsernameTreatedAsIdenticalUser || false,
+      ldapAttrMapMail: securitySettingParams.ldapAttrMapMail || '',
+      ldapAttrMapName: securitySettingParams.ldapAttrMapName || '',
+      ldapGroupSearchBase: securitySettingParams.ldapGroupSearchBase || '',
+      ldapGroupSearchFilter: securitySettingParams.ldapGroupSearchFilter || '',
+      ldapGroupDnProperty: securitySettingParams.ldapGroupDnProperty || '',
+    });
+    return response;
+  }
+
 }