login.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 isRegistrationEnabled = passportService.isLocalStrategySetup && getConfig('crowi', 'security:registrationMode') != 'Closed' %}
  93. <!-- [TODO][GW-1913] An AppContainer gets csrf data -->
  94. <div id="login-form"
  95. data-username ="{{ req.body.registerForm.username }}"
  96. data-name ="{{ req.body.registerForm.name }}"
  97. data-email ="{{ req.body.registerForm.email }}"
  98. data-csrf="{{ csrf() }}"
  99. ></div>
  100. </div>
  101. </div>
  102. </div>
  103. {% endblock %}
  104. {% block body_end %}
  105. <!-- [TODO][GW-1865] -->
  106. {% if isExternalAuthCollapsible %}
  107. <script>
  108. const isMobile = /iphone|ipad|android/.test(window.navigator.userAgent.toLowerCase());
  109. if (!isMobile) {
  110. $(".collapse-anchor").hover(
  111. function() {
  112. $('.collapse-external-auth').collapse('show');
  113. },
  114. function() {
  115. $('.collapse-external-auth').collapse('hide');
  116. }
  117. );
  118. }
  119. </script>
  120. {% endif %}
  121. <script>
  122. $('#register-form input[name="registerForm[username]"]').change(function(e) {
  123. var username = $(this).val();
  124. $('#login-dialog').removeClass('has-error');
  125. $('#input-group-username').removeClass('has-error');
  126. $('#help-block-username').html("");
  127. $.getJSON('/_api/check_username', {username: username}, function(json) {
  128. if (!json.valid) {
  129. $('#help-block-username').html(
  130. '<i class="icon-fw icon-ban"></i> This User ID is not available.'
  131. );
  132. $('#login-dialog').addClass('has-error');
  133. $('#input-group-username').addClass('has-error');
  134. }
  135. });
  136. });
  137. </script>
  138. {% endblock %}