login.html 6.6 KB

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