login.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. {% extends 'layout/layout.html' %}
  2. {% block html_base_css %}login-page nologin{% endblock %}
  3. {% block html_title %}{{ customizeService.generateCustomTitle(t('Sign in')) }}{% endblock %}
  4. {#
  5. # Remove default contents
  6. #}
  7. {% block html_head_loading_legacy %}
  8. {% endblock %}
  9. {% block html_head_loading_app %}
  10. {% endblock %}
  11. {% block layout_head_nav %}
  12. {% endblock %}
  13. {% block sidebar %}
  14. {% endblock %}
  15. {% block html_additional_headers %}
  16. <script src="{{ webpack_asset('js/nologin.js') }}" defer></script>
  17. {% endblock %}
  18. {% block layout_main %}
  19. <div class="main container-fluid">
  20. <div class="row">
  21. <div class="col-md-12">
  22. <div class="login-header mx-auto">
  23. <div class="logo mb-3">{% include 'widget/logo.html' %}</div>
  24. <h1>{{ appService.getAppTitle() }}</h1>
  25. <div class="login-form-errors px-3">
  26. {% if isLdapSetupFailed() %}
  27. <div class="alert alert-warning small">
  28. <strong><i class="icon-fw icon-info"></i>LDAP is enabled but the configuration has something wrong.</strong>
  29. <br>
  30. (Please set the environment variables <code>DEBUG=crowi:service:PassportService</code> to get the logs)
  31. </div>
  32. {% endif %}
  33. {#
  34. # The case that there already exists a user whose username matches ID of the newly created LDAP user
  35. # https://github.com/weseek/growi/issues/193
  36. #}
  37. {% set failedProviderForDuplicatedUsernameException = req.flash('provider-DuplicatedUsernameException') %}
  38. {% if failedProviderForDuplicatedUsernameException != null %}
  39. <div class="alert alert-warning small">
  40. <p><strong><i class="icon-fw icon-ban"></i>DuplicatedUsernameException occured</strong></p>
  41. <p>
  42. Your {{ failedProviderForDuplicatedUsernameException }} authentication was succeess, but a new user could not be created.
  43. See the issue <a href="https://github.com/weseek/growi/issues/193">#193</a>.
  44. </p>
  45. </div>
  46. {% endif %}
  47. {% set success = req.flash('successMessage') %}
  48. {% if success.length %}
  49. <div class="alert alert-success">
  50. {{ success }}
  51. </div>
  52. {% endif %}
  53. {% set warn = req.flash('warningMessage') %}
  54. {% if warn.length %}
  55. {% for w in warn %}
  56. <div class="alert alert-warning">
  57. {{ w }}
  58. </div>
  59. {% endfor %}
  60. {% endif %}
  61. {% set error = req.flash('errorMessage') %}
  62. {% if error.length %}
  63. {% for e in error %}
  64. <div class="alert alert-danger">
  65. {{ e }}
  66. </div>
  67. {% endfor %}
  68. {% endif %}
  69. {% if req.form.errors.length > 0 %}
  70. <div class="alert alert-danger">
  71. <ul>
  72. {% for error in req.form.errors %}
  73. <li>{{ error }}</li>
  74. {% endfor %}
  75. </ul>
  76. </div>
  77. {% endif %}
  78. </div>
  79. <div id="register-form-errors">
  80. {% set message = req.flash('registerWarningMessage') %}
  81. {% if message.length %}
  82. <div class="alert alert-danger">
  83. {% for msg in message %}
  84. {{ msg }}<br>
  85. {% endfor %}
  86. </div>
  87. {% endif %}
  88. </div>
  89. </div>
  90. {% set registrationMode = getConfig('crowi', 'security:registrationMode') %}
  91. {% set isRegistrationEnabled = passportService.isLocalStrategySetup && registrationMode != 'Closed' %}
  92. <div
  93. id="login-form"
  94. data-is-registering="{{ req.query.register or req.body.registerForm or isRegistering }}"
  95. data-username ="{{ req.body.registerForm.username }}"
  96. data-name ="{{ req.body.registerForm.name }}"
  97. data-email ="{{ req.body.registerForm.email }}"
  98. data-is-registration-enabled="{{ isRegistrationEnabled }}"
  99. data-registration-mode = "{{ registrationMode }}"
  100. data-registration-white-list = "{{ getConfig('crowi', 'security:registrationWhiteList') }}"
  101. data-is-local-strategy-setup = "{{ passportService.isLocalStrategySetup }}"
  102. data-is-ldap-strategy-setup = "{{ passportService.isLdapStrategySetup}}"
  103. data-is-google-auth-enabled = "{{ getConfig('crowi', 'security:passport-google:isEnabled') }}"
  104. data-is-github-auth-enabled = "{{ getConfig('crowi', 'security:passport-github:isEnabled') }}"
  105. data-is-facebook-auth-enabled = "{{ getConfig('crowi', 'security:passport-facebook:isEnabled') }}"
  106. data-is-twitter-auth-enabled = "{{ getConfig('crowi', 'security:passport-twitter:isEnabled') }}"
  107. data-is-saml-auth-enabled = "{{ getConfig('crowi', 'security:passport-saml:isEnabled') }}"
  108. data-is-oidc-auth-enabled = "{{ getConfig('crowi', 'security:passport-oidc:isEnabled') }}"
  109. data-is-basic-auth-enabled = "{{ getConfig('crowi', 'security:passport-basic:isEnabled') }}"
  110. ></div>
  111. </div>
  112. </div>
  113. </div>
  114. {% endblock %}
  115. {% block body_end %}
  116. <script>
  117. $('#register-form input[name="registerForm[username]"]').change(function(e) {
  118. var username = $(this).val();
  119. $('#login-dialog').removeClass('has-error');
  120. $('#input-group-username').removeClass('has-error');
  121. $('#help-block-username').html("");
  122. $.getJSON('/_api/check_username', {username: username}, function(json) {
  123. if (!json.valid) {
  124. $('#help-block-username').html(
  125. '<i class="icon-fw icon-ban"></i> This User ID is not available.'
  126. );
  127. $('#login-dialog').addClass('has-error');
  128. $('#input-group-username').addClass('has-error');
  129. }
  130. });
  131. });
  132. </script>
  133. {% endblock %}