login.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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="row">
  26. <div class="login-form-errors col-12">
  27. {% if isLdapSetupFailed() %}
  28. <div class="alert alert-warning small">
  29. <strong><i class="icon-fw icon-info"></i>LDAP is enabled but the configuration has something wrong.</strong>
  30. <br>
  31. (Please set the environment variables <code>DEBUG=crowi:service:PassportService</code> to get the logs)
  32. </div>
  33. {% endif %}
  34. {#
  35. # The case that there already exists a user whose username matches ID of the newly created LDAP user
  36. # https://github.com/weseek/growi/issues/193
  37. #}
  38. {% set failedProviderForDuplicatedUsernameException = req.flash('provider-DuplicatedUsernameException') %}
  39. {% if failedProviderForDuplicatedUsernameException != null %}
  40. <div class="alert alert-warning small">
  41. <p><strong><i class="icon-fw icon-ban"></i>DuplicatedUsernameException occured</strong></p>
  42. <p>
  43. Your {{ failedProviderForDuplicatedUsernameException }} authentication was succeess, but a new user could not be created.
  44. See the issue <a href="https://github.com/weseek/growi/issues/193">#193</a>.
  45. </p>
  46. </div>
  47. {% endif %}
  48. {% set success = req.flash('successMessage') %}
  49. {% if success.length %}
  50. <div class="alert alert-success">
  51. {{ success }}
  52. </div>
  53. {% endif %}
  54. {% set warn = req.flash('warningMessage') %}
  55. {% if warn.length %}
  56. {% for w in warn %}
  57. <div class="alert alert-warning">
  58. {{ w }}
  59. </div>
  60. {% endfor %}
  61. {% endif %}
  62. {% set error = req.flash('errorMessage') %}
  63. {% if error.length %}
  64. {% for e in error %}
  65. <div class="alert alert-danger">
  66. {{ e }}
  67. </div>
  68. {% endfor %}
  69. {% endif %}
  70. {% if req.form.errors.length > 0 %}
  71. <div class="alert alert-danger">
  72. <ul>
  73. {% for error in req.form.errors %}
  74. <li>{{ error }}</li>
  75. {% endfor %}
  76. </ul>
  77. </div>
  78. {% endif %}
  79. </div>
  80. <div id="register-form-errors">
  81. {% set message = req.flash('registerWarningMessage') %}
  82. {% if message.length %}
  83. <div class="alert alert-danger">
  84. {% for msg in message %}
  85. {{ msg }}<br>
  86. {% endfor %}
  87. </div>
  88. {% endif %}
  89. </div>
  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 %}