AdminGeneralSecurityContainer.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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:AdminGeneralSecurityContainer');
  5. /**
  6. * Service container for admin security page (SecurityManagement.jsx)
  7. * @extends {Container} unstated Container
  8. */
  9. export default class AdminGeneralSecurityContainer 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. isLdapEnabled: true,
  20. isSamlEnabled: true,
  21. };
  22. this.init();
  23. this.switchIsLocalEnabled = this.switchIsLocalEnabled.bind(this);
  24. this.changeRegistrationMode = this.changeRegistrationMode.bind(this);
  25. }
  26. init() {
  27. // TODO GW-583 fetch config value with api
  28. }
  29. /**
  30. * Workaround for the mangling in production build to break constructor.name
  31. */
  32. static getClassName() {
  33. return 'AdminGeneralSecurityContainer';
  34. }
  35. /**
  36. * Switch local enabled
  37. */
  38. switchIsLocalEnabled() {
  39. this.setState({ isLocalEnabled: !this.state.isLocalEnabled });
  40. }
  41. /**
  42. * Change registration mode
  43. */
  44. changeRegistrationMode(value) {
  45. this.setState({ registrationMode: value });
  46. }
  47. /**
  48. * Switch LDAP enabled
  49. */
  50. switchIsLdapEnabled() {
  51. this.setState({ isLdapEnabled: !this.state.isLdapEnabled });
  52. }
  53. /**
  54. * Switch SAML enabled
  55. */
  56. switchIsSamlEnabled() {
  57. this.setState({ isSamlEnabled: !this.state.isSamlEnabled });
  58. }
  59. }