2
0

AdminGeneralSecurityContainer.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. isOidcEnabled: true,
  22. };
  23. this.init();
  24. this.switchIsLocalEnabled = this.switchIsLocalEnabled.bind(this);
  25. this.changeRegistrationMode = this.changeRegistrationMode.bind(this);
  26. }
  27. init() {
  28. // TODO GW-583 fetch config value with api
  29. }
  30. /**
  31. * Workaround for the mangling in production build to break constructor.name
  32. */
  33. static getClassName() {
  34. return 'AdminGeneralSecurityContainer';
  35. }
  36. /**
  37. * Switch local enabled
  38. */
  39. switchIsLocalEnabled() {
  40. this.setState({ isLocalEnabled: !this.state.isLocalEnabled });
  41. }
  42. /**
  43. * Change registration mode
  44. */
  45. changeRegistrationMode(value) {
  46. this.setState({ registrationMode: value });
  47. }
  48. /**
  49. * Switch LDAP enabled
  50. */
  51. switchIsLdapEnabled() {
  52. this.setState({ isLdapEnabled: !this.state.isLdapEnabled });
  53. }
  54. /**
  55. * Switch SAML enabled
  56. */
  57. switchIsSamlEnabled() {
  58. this.setState({ isSamlEnabled: !this.state.isSamlEnabled });
  59. }
  60. /**
  61. * Switch Oidc enabled
  62. */
  63. switchIsOidcEnabled() {
  64. this.setState({ isOidcEnabled: !this.state.isOidcEnabled });
  65. }
  66. }