login.html 5.8 KB

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