AdminLdapSecurityContainer.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import { Container } from 'unstated';
  2. import loggerFactory from '@alias/logger';
  3. // eslint-disable-next-line no-unused-vars
  4. const logger = loggerFactory('growi:security:AdminLdapSecurityContainer');
  5. /**
  6. * Service container for admin security page (SecurityLdapSetting.jsx)
  7. * @extends {Container} unstated Container
  8. */
  9. export default class AdminLdapSecurityContainer extends Container {
  10. constructor(appContainer) {
  11. super();
  12. this.appContainer = appContainer;
  13. this.state = {
  14. // TODO GW-583 set value
  15. serverUrl: '',
  16. ldapBindMode: 'manager',
  17. ldapBindDN: '',
  18. ldapBindDNPassword: '',
  19. ldapSearchFilter: '',
  20. ldapAttrMapUsername: '',
  21. cbSameUsernameTreatedAsIdenticalUser: false,
  22. ldapAttrMapMail: '',
  23. ldapAttrMapName: '',
  24. ldapGroupSearchBase: '',
  25. ldapGroupSearchFilter: '',
  26. ldapGroupDnProperty: '',
  27. };
  28. this.init();
  29. }
  30. init() {
  31. // TODO GW-583 fetch config value with api
  32. }
  33. /**
  34. * Workaround for the mangling in production build to break constructor.name
  35. */
  36. static getClassName() {
  37. return 'AdminLdapSecurityContainer';
  38. }
  39. /**
  40. * Change server url
  41. */
  42. changeServerUrl(inputValue) {
  43. this.setState({ serverUrl: inputValue });
  44. }
  45. /**
  46. * Change ldap bind mode
  47. */
  48. changeLdapBindMode(mode) {
  49. this.setState({ bindMode: mode });
  50. }
  51. /**
  52. * Change bind DN
  53. */
  54. changeBindDN(inputValue) {
  55. this.setState({ bindDN: inputValue });
  56. }
  57. /**
  58. * Change bind DN password
  59. */
  60. changeBindDNPassword(inputValue) {
  61. this.setState({ bindDNPassword: inputValue });
  62. }
  63. /**
  64. * Change search filter
  65. */
  66. changeSearchFilter(inputValue) {
  67. this.setState({ searchFilter: inputValue });
  68. }
  69. /**
  70. * Change attr map username
  71. */
  72. changeAttrMapUsername(inputValue) {
  73. this.setState({ attrMapUsername: inputValue });
  74. }
  75. /**
  76. * Switch cb same username treated as identical user
  77. */
  78. switchCbSameUsernameTreatedAsIdenticalUser() {
  79. this.setState({ cbSameUsernameTreatedAsIdenticalUser: !this.state.cbSameUsernameTreatedAsIdenticalUser });
  80. }
  81. /**
  82. * Change attr map email
  83. */
  84. changeAttrMapMail(inputValue) {
  85. this.setState({ attrMapMail: inputValue });
  86. }
  87. /**
  88. * Change attr map name
  89. */
  90. changeAttrMapName(inputValue) {
  91. this.setState({ attrMapName: inputValue });
  92. }
  93. /**
  94. * Change group search base
  95. */
  96. changeGroupSearchBase(inputValue) {
  97. this.setState({ groupSearchBase: inputValue });
  98. }
  99. /**
  100. * Change group search filter
  101. */
  102. changeGroupSearchFilter(inputValue) {
  103. this.setState({ groupSearchFilter: inputValue });
  104. }
  105. /**
  106. * Change group dn property
  107. */
  108. changeGroupDnProperty(inputValue) {
  109. this.setState({ groupDnProperty: inputValue });
  110. }
  111. }