login.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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() }}</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. {% if req.form.errors.length > 0 %}
  74. <div class="alert alert-danger">
  75. <ul class="mb-0">
  76. {% for error in req.form.errors %}
  77. <li>{{ error }}</li>
  78. {% endfor %}
  79. </ul>
  80. </div>
  81. {% endif %}
  82. </div>
  83. <div id="register-form-errors" class="px-3">
  84. {% set message = req.flash('registerWarningMessage') %}
  85. {% if message.length %}
  86. <div class="alert alert-danger">
  87. {% for msg in message %}
  88. {{ msg }}<br>
  89. {% endfor %}
  90. </div>
  91. {% endif %}
  92. </div>
  93. </div>
  94. {% set registrationMode = getConfig('crowi', 'security:registrationMode') %}
  95. {% set isRegistrationEnabled = passportService.isLocalStrategySetup && registrationMode != 'Closed' %}
  96. <div
  97. id="login-form"
  98. data-is-registering="{{ req.query.register or req.body.registerForm or isRegistering }}"
  99. data-username ="{{ req.body.registerForm.username }}"
  100. data-name ="{{ req.body.registerForm.name }}"
  101. data-email ="{{ req.body.registerForm.email }}"
  102. data-is-registration-enabled="{{ isRegistrationEnabled }}"
  103. data-registration-mode = "{{ registrationMode }}"
  104. data-registration-white-list = "{{ getConfig('crowi', 'security:registrationWhiteList') }}"
  105. data-is-local-strategy-setup = "{{ passportService.isLocalStrategySetup }}"
  106. data-is-ldap-strategy-setup = "{{ passportService.isLdapStrategySetup}}"
  107. data-is-google-auth-enabled = "{{ getConfig('crowi', 'security:passport-google:isEnabled') }}"
  108. data-is-github-auth-enabled = "{{ getConfig('crowi', 'security:passport-github:isEnabled') }}"
  109. data-is-facebook-auth-enabled = "{{ getConfig('crowi', 'security:passport-facebook:isEnabled') }}"
  110. data-is-twitter-auth-enabled = "{{ getConfig('crowi', 'security:passport-twitter:isEnabled') }}"
  111. data-is-saml-auth-enabled = "{{ getConfig('crowi', 'security:passport-saml:isEnabled') }}"
  112. data-is-oidc-auth-enabled = "{{ getConfig('crowi', 'security:passport-oidc:isEnabled') }}"
  113. data-is-basic-auth-enabled = "{{ getConfig('crowi', 'security:passport-basic:isEnabled') }}"
  114. ></div>
  115. </div>
  116. </div>
  117. </div>
  118. {% endblock %}
  119. {% block body_end %}
  120. <script>
  121. $('#register-form input[name="registerForm[username]"]').change(function(e) {
  122. var username = $(this).val();
  123. $('#login-dialog').removeClass('has-error');
  124. $('#input-group-username').removeClass('has-error');
  125. $('#help-block-username').html("");
  126. $.getJSON('/_api/check_username', {username: username}, function(json) {
  127. if (!json.valid) {
  128. $('#help-block-username').html(
  129. '<i class="icon-fw icon-ban"></i> This User ID is not available.'
  130. );
  131. $('#login-dialog').addClass('has-error');
  132. $('#input-group-username').addClass('has-error');
  133. }
  134. });
  135. });
  136. </script>
  137. {% endblock %}