login.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. {% extends 'layout/layout.html' %}
  2. {% block html_base_css %}login-page nologin{% endblock %}
  3. {% block html_title %}{{ 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 layout_main %}
  16. <div class="main container-fluid">
  17. <div class="row">
  18. <div class="login-header col-sm-offset-4 col-sm-4 text-center">
  19. <div class="logo">{% include 'widget/logo.html' %}</div>
  20. <h1>
  21. {{ config.crowi['app:title'] || 'GROWI' }}
  22. </h1>
  23. </div>
  24. <div class="login-dialog p-b-10 col-sm-offset-4 col-sm-4 flipper {% if req.query.register or req.body.registerForm or isRegistering or googleId %}to-flip{% endif %}" id="login-dialog">
  25. <div class="front">
  26. <div id="login-form-errors">
  27. {% if isLdapSetupFailed() %}
  28. <div class="alert alert-warning">
  29. LDAP is enabled but the configuration has something wrong.<br>
  30. <small>(set the environment variables <code>DEBUG=crowi:service:PassportService</code> and get the logs)</small>
  31. </div>
  32. {% endif %}
  33. {#
  34. # The case that there already exists a user whose username matches ID of the newly created LDAP user
  35. # https://github.com/weseek/crowi-plus/issues/193
  36. #}
  37. {% set isDuplicatedUsernameExceptionOccured = req.flash('isDuplicatedUsernameExceptionOccured') %}
  38. {% if isDuplicatedUsernameExceptionOccured != null %}
  39. <div class="alert alert-warning">
  40. <i class="fa fa-fw fa-info-circle"></i>
  41. <strong>DuplicatedUsernameException occured</strong>
  42. <p>
  43. Your LDAP authentication was succeess, but a new user could not be created.
  44. See the issue <a href="https://github.com/weseek/crowi-plus/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. <form role="form" action="/login" method="post">
  81. <div class="input-group">
  82. <span class="input-group-addon"><i class="icon-fw icon-user"></i></span>
  83. <input type="text" class="form-control" placeholder="Username or E-mail" name="loginForm[username]">
  84. {% if isLdapSetup() %}
  85. <span class="input-group-addon">
  86. <small class="text-primary">
  87. <i class="fa fa-fw fa-check-circle"></i> LDAP
  88. </small>
  89. </span>
  90. {% endif %}
  91. </div>
  92. <div class="input-group">
  93. <span class="input-group-addon"><i class="icon-fw icon-lock"></i></span>
  94. <input type="password" class="form-control" placeholder="Password" name="loginForm[password]">
  95. </div>
  96. <div class="input-group m-t-30 m-b-20 d-flex justify-content-center">
  97. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  98. <button type="submit" class="fcbtn btn btn-danger btn-1b btn-login">
  99. <span class="btn-label"><i class="icon-login"></i></span>
  100. {{ t('Sign in') }}
  101. </button>
  102. </div>
  103. </form>
  104. <hr>
  105. <div class="row">
  106. {% if googleLoginEnabled() %}
  107. <div class="col-md-8">
  108. <p>{{ t('Sign in by Google Account') }}</p>
  109. <form role="form" action="/login/google" method="get">
  110. <button type="submit" class="btn btn-block btn-google"><i class="fa fa-google-plus-square"></i> {{ t('Sign in') }}</button>
  111. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  112. </form>
  113. </div>
  114. {% endif %}
  115. </div>
  116. {% if config.crowi['security:registrationMode'] != 'Closed' %}
  117. <a href="#register" id="register" class="pull-right link-switch">
  118. <i class="ti-check-box"></i> {{ t('Sign up is here') }}
  119. </a>
  120. {% endif %}
  121. </div>
  122. {% if config.crowi['security:registrationMode'] != 'Closed' %}
  123. <div class="back">
  124. {% if config.crowi['security:registrationMode'] == 'Restricted' %}
  125. <p class="alert alert-warning">
  126. {{ t('page_register.notice.restricted') }}<br>
  127. {{ t('page_register.notice.restricted_defail') }}
  128. </p>
  129. {% endif %}
  130. {% if googleId %}
  131. <div class="google-info alert alert-info">
  132. {% if googleImage %}
  133. <p class="text-center">
  134. <img src="{{ googleImage }}" class="img-circle img-circle-lg">
  135. </p>
  136. {% endif %}
  137. <code>{{ googleEmail }}</code> {{ t('page_register with this Google Account') }}<br>
  138. {{ t('page_register.notice.google_account_continue') }}
  139. </div>
  140. {% endif %}
  141. <div id="register-form-errors">
  142. {% set message = req.flash('registerWarningMessage') %}
  143. {% if message.length %}
  144. <div class="alert alert-danger">
  145. {% for msg in message %}
  146. {{ msg }}<br>
  147. {% endfor %}
  148. </div>
  149. {% endif %}
  150. {% if req.form.errors.length > 0 %}
  151. <div class="alert alert-danger">
  152. <ul>
  153. {% for error in req.form.errors %}
  154. <li>{{ error }}</li>
  155. {% endfor %}
  156. </ul>
  157. </div>
  158. {% endif %}
  159. </div>
  160. <form role="form" method="post" action="/register" id="register-form">
  161. <input type="hidden" class="form-control" name="registerForm[googleId]" value="{{ googleId|default(req.body.registerForm.googleId) }}">
  162. <div class="input-group" id="input-group-username">
  163. <span class="input-group-addon"><i class="icon-user"></i></span>
  164. <input type="text" class="form-control" placeholder="{{ t('User ID') }}" name="registerForm[username]" value="{{ req.body.registerForm.username }}" required>
  165. </div>
  166. <div class="input-group">
  167. <span class="input-group-addon"><i class="icon-tag"></i></span>
  168. <input type="text" class="form-control" placeholder="{{ t('Name') }}" name="registerForm[name]" value="{{ googleName|default(req.body.registerForm.name) }}" required>
  169. </div>
  170. <div class="input-group">
  171. <span class="input-group-addon"><i class="icon-envelope"></i></span>
  172. <input type="email" class="form-control" placeholder="{{ t('Email') }}" name="registerForm[email]" value="{{ googleEmail|default(req.body.registerForm.email) }}" required>
  173. </div>
  174. {% if config.crowi['security:registrationWhiteList'] && config.crowi['security:registrationWhiteList'].length %}
  175. <p class="help-block">
  176. {{ t('page_register.form_help.email') }}
  177. </p>
  178. <ul>
  179. {% for em in config.crowi['security:registrationWhiteList'] %}
  180. <li><code>{{ em }}</code></li>
  181. {% endfor %}
  182. </ul>
  183. {% endif %}
  184. <div class="input-group">
  185. <span class="input-group-addon"><i class="icon-lock"></i></span>
  186. <input type="password" class="form-control" placeholder="{{ t('Password') }}" name="registerForm[password]" required>
  187. </div>
  188. {% if googleImage %}
  189. <input type="hidden" name="registerForm[googleImage]" value="{{ googleImage }}">
  190. {% endif %}
  191. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  192. <div class="input-group m-t-30 m-b-20 d-flex justify-content-center">
  193. <button type="submit" class="fcbtn btn btn-success btn-1b btn-register">
  194. <span class="btn-label"><i class="icon-user-follow"></i></span>
  195. {{ t('Sign up') }}
  196. </button>
  197. </div>
  198. </form>
  199. <hr>
  200. <div class="row">
  201. {% if googleLoginEnabled() %}
  202. <div class="col-md-6">
  203. <p>{{ t('Sign up with Google Account') }}</p>
  204. <form role="form" method="post" action="/register/google">
  205. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  206. <button type="submit" class="btn btn-block btn-google"><i class="fa fa-google-plus-square"></i> {{ t('Login') }}</button>
  207. </form>
  208. </div>
  209. {% endif %}
  210. </div>
  211. <a href="#login" id="login" class="pull-right link-switch">
  212. <i class="icon-fw icon-login"></i>{{ t('Sign in is here') }}
  213. </a>
  214. </div>
  215. {% endif %} {# if registrationMode == Closed #}
  216. <a href="https://growi.org" class="link-growi-org">
  217. <span class="growi">GROWI</span>.<span class="org">ORG
  218. </a>
  219. </div>
  220. </div>
  221. </div>
  222. {% endblock %}
  223. {% block body_end %}
  224. <script>
  225. // login
  226. $('#register').on('click', function() {
  227. $('#login-dialog').addClass('to-flip');
  228. return false;
  229. });
  230. $('#login').on('click', function() {
  231. $('#login-dialog').removeClass('to-flip');
  232. return false;
  233. });
  234. $('#register-form input[name="registerForm[username]"]').change(function(e) {
  235. var username = $(this).val();
  236. $('#input-group-username').removeClass('has-error');
  237. $('#help-block-username').html("");
  238. $.getJSON('/_api/check_username', {username: username}, function(json) {
  239. if (!json.valid) {
  240. $('#help-block-username').html('<i class="fa fa-warning"></i> This User ID is not available.<br>');
  241. $('#input-group-username').addClass('has-error');
  242. }
  243. });
  244. });
  245. </script>
  246. {% endblock %}