AdminGeneralSecurityContainer.js 1.8 KB

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