AdminSecurityContainer.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { Container } from 'unstated';
  2. import loggerFactory from '@alias/logger';
  3. // eslint-disable-next-line no-unused-vars
  4. const logger = loggerFactory('growi:services:AdminSecurityContainer');
  5. /**
  6. * Service container for admin security page (SecurityManagement.jsx)
  7. * @extends {Container} unstated Container
  8. */
  9. export default class AdminSecurityContainer extends Container {
  10. constructor(appContainer) {
  11. super();
  12. this.appContainer = appContainer;
  13. this.state = {
  14. // TODO GW-583 set value
  15. useOnlyEnvVarsForSomeOptions: true,
  16. isLocalEnabled: true,
  17. registrationMode: 'open',
  18. registrationWhiteList: '',
  19. ldapConfig: {
  20. isEnabled: true,
  21. serverUrl: '',
  22. },
  23. };
  24. this.init();
  25. this.switchIsLocalEnabled = this.switchIsLocalEnabled.bind(this);
  26. this.changeRegistrationMode = this.changeRegistrationMode.bind(this);
  27. this.switchIsLdapEnabled = this.switchIsLdapEnabled.bind(this);
  28. }
  29. init() {
  30. // TODO GW-583 fetch config value with api
  31. }
  32. /**
  33. * Workaround for the mangling in production build to break constructor.name
  34. */
  35. static getClassName() {
  36. return 'AdminSecurityContainer';
  37. }
  38. /**
  39. * Switch local enabled
  40. */
  41. switchIsLocalEnabled() {
  42. this.setState({ isLocalEnabled: !this.state.isLocalEnabled });
  43. }
  44. /**
  45. * Change registration mode
  46. */
  47. changeRegistrationMode(value) {
  48. this.setState({ registrationMode: value });
  49. }
  50. /**
  51. * Switch local enabled
  52. */
  53. switchIsLdapEnabled() {
  54. this.setState({ isLdapEnabled: !this.state.isLdapEnabled });
  55. }
  56. }