login.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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 layout_main %}
  16. <div class="main container-fluid">
  17. <div class="row">
  18. <div class="col-md-12">
  19. <div class="login-header mx-auto">
  20. <div class="logo mb-3">{% include 'widget/logo.html' %}</div>
  21. <h1>{{ appService.getAppTitle() }}</h1>
  22. <div class="row">
  23. <div class="login-form-errors col-12">
  24. {% if isLdapSetupFailed() %}
  25. <div class="alert alert-warning small">
  26. <strong><i class="icon-fw icon-info"></i>LDAP is enabled but the configuration has something wrong.</strong>
  27. <br>
  28. (Please set the environment variables <code>DEBUG=crowi:service:PassportService</code> to get the logs)
  29. </div>
  30. {% endif %}
  31. {#
  32. # The case that there already exists a user whose username matches ID of the newly created LDAP user
  33. # https://github.com/weseek/growi/issues/193
  34. #}
  35. {% set failedProviderForDuplicatedUsernameException = req.flash('provider-DuplicatedUsernameException') %}
  36. {% if failedProviderForDuplicatedUsernameException != null %}
  37. <div class="alert alert-warning small">
  38. <p><strong><i class="icon-fw icon-ban"></i>DuplicatedUsernameException occured</strong></p>
  39. <p>
  40. Your {{ failedProviderForDuplicatedUsernameException }} authentication was succeess, but a new user could not be created.
  41. See the issue <a href="https://github.com/weseek/growi/issues/193">#193</a>.
  42. </p>
  43. </div>
  44. {% endif %}
  45. {% set success = req.flash('successMessage') %}
  46. {% if success.length %}
  47. <div class="alert alert-success">
  48. {{ success }}
  49. </div>
  50. {% endif %}
  51. {% set warn = req.flash('warningMessage') %}
  52. {% if warn.length %}
  53. {% for w in warn %}
  54. <div class="alert alert-warning">
  55. {{ w }}
  56. </div>
  57. {% endfor %}
  58. {% endif %}
  59. {% set error = req.flash('errorMessage') %}
  60. {% if error.length %}
  61. {% for e in error %}
  62. <div class="alert alert-danger">
  63. {{ e }}
  64. </div>
  65. {% endfor %}
  66. {% endif %}
  67. {% if req.form.errors.length > 0 %}
  68. <div class="alert alert-danger">
  69. <ul>
  70. {% for error in req.form.errors %}
  71. <li>{{ error }}</li>
  72. {% endfor %}
  73. </ul>
  74. </div>
  75. {% endif %}
  76. </div>
  77. <div id="register-form-errors">
  78. {% set message = req.flash('registerWarningMessage') %}
  79. {% if message.length %}
  80. <div class="alert alert-danger">
  81. {% for msg in message %}
  82. {{ msg }}<br>
  83. {% endfor %}
  84. </div>
  85. {% endif %}
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. <div class="row mb-5">
  92. <div class="col-md-12">
  93. {% set isLocalOrLdapStrategiesEnabled = passportService.isLocalStrategySetup || passportService.isLdapStrategySetup %}
  94. {% set isExternalAuthCollapsible = isLocalOrLdapStrategiesEnabled %}
  95. {% set isRegistrationEnabled = passportService.isLocalStrategySetup && getConfig('crowi', 'security:registrationMode') != 'Closed' %}
  96. <div id="login-form"></div>
  97. <!-- [TODO][GW-1772][GW-1863] remove the old login-form -->
  98. <div class="login-dialog mx-auto flipper {% if req.query.register or req.body.registerForm or isRegistering %}to-flip{% endif %}" id="login-dialog">
  99. <div class="col-12">
  100. <div class="front">
  101. {% if isLocalOrLdapStrategiesEnabled %}
  102. <form role="form" action="/login" method="post">
  103. <div class="input-group mb-3">
  104. <div class="input-group-prepend">
  105. <span class="input-group-text"><i class="icon-user"></i></span>
  106. </div>
  107. <input type="text" class="form-control" placeholder="Username or E-mail" name="loginForm[username]">
  108. {% if passportService.isLdapStrategySetup %}
  109. <div class="input-group-append">
  110. <small class="input-group-text text-success">
  111. <i class="icon-fw icon-check"></i> LDAP
  112. </small>
  113. </div>
  114. {% endif %}
  115. </div>
  116. <div class="input-group">
  117. <div class="input-group-prepend">
  118. <span class="input-group-text"><i class="icon-lock"></i></span>
  119. </div>
  120. <input type="password" class="form-control" placeholder="Password" name="loginForm[password]">
  121. </div>
  122. <div class="input-group justify-content-center d-flex mt-5">
  123. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  124. <button type="submit" class="btn btn-fill login px-0 py-2">
  125. <div class="eff"></div>
  126. <span class="btn-label p-3"><i class="icon-login"></i></span>
  127. <span class="btn-label-text p-3">{{ t('Sign in') }}</span>
  128. </button>
  129. </div>
  130. </form>
  131. {% endif %}
  132. {% if (
  133. getConfig('crowi', 'security:passport-google:isEnabled') ||
  134. getConfig('crowi', 'security:passport-github:isEnabled') ||
  135. getConfig('crowi', 'security:passport-facebook:isEnabled') ||
  136. getConfig('crowi', 'security:passport-twitter:isEnabled')||
  137. getConfig('crowi', 'security:passport-oidc:isEnabled') ||
  138. getConfig('crowi', 'security:passport-saml:isEnabled') ||
  139. getConfig('crowi', 'security:passport-basic:isEnabled')
  140. ) %}
  141. <div class="border-bottom"></div>
  142. <div id="external-auth" class="external-auth {% if isExternalAuthCollapsible %}collapse collapse-external-auth collapse-anchor{% endif %}">
  143. <div class="spacer"></div>
  144. <div class="d-flex flex-row justify-content-between flex-wrap">
  145. {% if getConfig('crowi', 'security:passport-google:isEnabled') %}
  146. <div class="input-group justify-content-center d-flex mt-5">
  147. <form role="form" action="/passport/google" class="d-inline-flex flex-column">
  148. <button type="submit" class="btn btn-fill px-0 py-2" id="google">
  149. <div class="eff"></div>
  150. <span class="btn-label p-3"><i class="fa fa-google"></i></span>
  151. <span class="btn-label-text p-3">{{ t('Sign in') }}</span>
  152. </button>
  153. <div class="small text-center">by Google Account</div>
  154. </form>
  155. </div>
  156. {% endif %}
  157. {% if getConfig('crowi', 'security:passport-github:isEnabled') %}
  158. <div class="input-group justify-content-center d-flex mt-5">
  159. <form role="form" action="/passport/github" class="d-inline-flex flex-column">
  160. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  161. <button type="submit" class="btn btn-fill px-0 py-2" id="github">
  162. <div class="eff"></div>
  163. <span class="btn-label p-3"><i class="fa fa-github"></i></span>
  164. <span class="btn-label-text p-3">{{ t('Sign in') }}</span>
  165. </button>
  166. <div class="small text-center">by GitHub Account</div>
  167. </form>
  168. </div>
  169. {% endif %}
  170. {% if getConfig('crowi', 'security:passport-facebook:isEnabled') %}
  171. <div class="input-group justify-content-center d-flex mt-5">
  172. <form role="form" action="/passport/facebook" class="d-inline-flex flex-column">
  173. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  174. <button type="submit" class="btn btn-fill px-0 py-2" id="facebook">
  175. <div class="eff"></div>
  176. <span class="btn-label p-3"><i class="fa fa-facebook"></i></span>
  177. <span class="btn-label-text p-3">{{ t('Sign in') }}</span>
  178. </button>
  179. <div class="small text-center">by Facebook Account</div>
  180. </form>
  181. </div>
  182. {% endif %}
  183. {% if getConfig('crowi', 'security:passport-twitter:isEnabled') %}
  184. <div class="input-group justify-content-center d-flex mt-5">
  185. <form role="form" action="/passport/twitter" class="d-inline-flex flex-column">
  186. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  187. <button type="submit" class="btn btn-fill px-0 py-2" id="twitter">
  188. <div class="eff"></div>
  189. <span class="btn-label p-3"><i class="fa fa-twitter"></i></span>
  190. <span class="btn-label-text p-3">{{ t('Sign in') }}</span>
  191. </button>
  192. <div class="small text-center">by Twitter Account</div>
  193. </form>
  194. </div>
  195. {% endif %}
  196. {% if getConfig('crowi', 'security:passport-oidc:isEnabled') %}
  197. <div class="input-group justify-content-center d-flex mt-5">
  198. <form role="form" action="/passport/oidc" class="d-inline-flex flex-column">
  199. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  200. <button type="submit" class="btn btn-fill px-0 py-2" id="oidc">
  201. <div class="eff"></div>
  202. <span class="btn-label p-3"><i class="fa fa-openid"></i></span>
  203. <span class="btn-label-text p-3">{{ t('Sign in') }}</span>
  204. </button>
  205. <div class="small text-center">{{ getConfig('crowi', 'security:passport-oidc:providerName') || "OpenID Connect" }}</div>
  206. </form>
  207. </div>
  208. {% endif %}
  209. {% if getConfig('crowi', 'security:passport-saml:isEnabled') %}
  210. <div class="input-group justify-content-center d-flex mt-5">
  211. <form role="form" action="/passport/saml" class="d-inline-flex flex-column">
  212. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  213. <button type="submit" class="btn btn-fill px-0 py-2" id="saml">
  214. <div class="eff"></div>
  215. <span class="btn-label p-3"><i class="fa fa-key"></i></span>
  216. <span class="btn-label-text p-3">{{ t('Sign in') }}</span>
  217. </button>
  218. <div class="small text-center">with SAML</div>
  219. </form>
  220. </div>
  221. {% endif %}
  222. {% if getConfig('crowi', 'security:passport-basic:isEnabled') %}
  223. <div class="input-group justify-content-center d-flex mt-5">
  224. <form role="form" action="/passport/basic" class="d-inline-flex flex-column">
  225. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  226. <button type="submit" class="btn btn-fill px-0 py-2" id="basic">
  227. <div class="eff"></div>
  228. <span class="btn-label p-3"><i class="fa fa-lock"></i></span>
  229. <span class="btn-label-text p-3">{{ t('Sign in') }}</span>
  230. </button>
  231. <div class="small text-center">with Basic Auth</div>
  232. </form>
  233. </div>
  234. {% endif %}
  235. </div>{# ./d-flex flex-row flex-wrap #}
  236. <div class="spacer"></div>
  237. </div>
  238. <div class="border-bottom"></div>
  239. <div class="text-center">
  240. <button class="collapse-anchor btn btn-xs btn-collapse-external-auth mb-3"
  241. data-toggle="{% if isExternalAuthCollapsible %}collapse{% endif %}" data-target="#external-auth" aria-expanded="false" aria-controls="external-auth">
  242. External Auth
  243. </button>
  244. </div>
  245. {% else %}
  246. <div class="border-bottom mb-3"></div>
  247. {% endif %}
  248. {% if isExternalAuthCollapsible %}
  249. <script>
  250. const isMobile = /iphone|ipad|android/.test(window.navigator.userAgent.toLowerCase());
  251. if (!isMobile) {
  252. $(".collapse-anchor").hover(
  253. function() {
  254. $('.collapse-external-auth').collapse('show');
  255. },
  256. function() {
  257. $('.collapse-external-auth').collapse('hide');
  258. }
  259. );
  260. }
  261. </script>
  262. {% endif %}
  263. <div class="row">
  264. <div class="col-12 text-right py-2">
  265. {% if isRegistrationEnabled %}
  266. <a href="#register" id="register" class="link-switch">
  267. <i class="ti-check-box"></i> {{ t('Sign up is here') }}
  268. </a>
  269. {% else %}
  270. &nbsp;
  271. {% endif %}
  272. </div>
  273. </div>
  274. </div>
  275. {% if isRegistrationEnabled %}
  276. <div class="back">
  277. {% if getConfig('crowi', 'security:registrationMode') == 'Restricted' %}
  278. <p class="alert alert-warning">
  279. {{ t('page_register.notice.restricted') }}<br>
  280. {{ t('page_register.notice.restricted_defail') }}
  281. </p>
  282. {% endif %}
  283. <form role="form" action="/register" method="post" id="register-form">
  284. <div class="input-group" id="input-group-username">
  285. <div class="input-group-prepend">
  286. <span class="input-group-text"><i class="icon-user"></i></span>
  287. </div>
  288. <input type="text" class="form-control" placeholder="{{ t('User ID') }}" name="registerForm[username]" value="{{ req.body.registerForm.username }}" required>
  289. </div>
  290. <p class="form-text text-danger">
  291. <span id="help-block-username"></span>
  292. </p>
  293. <div class="input-group">
  294. <div class="input-group-prepend">
  295. <span class="input-group-text"><i class="icon-tag"></i></span>
  296. </div>
  297. <input type="text" class="form-control" placeholder="{{ t('Name') }}" name="registerForm[name]" value="{{ req.body.registerForm.name }}" required>
  298. </div>
  299. <div class="input-group">
  300. <div class="input-group-prepend">
  301. <span class="input-group-text"><i class="icon-envelope"></i></span>
  302. </div>
  303. <input type="email" class="form-control" placeholder="{{ t('Email') }}" name="registerForm[email]" value="{{ req.body.registerForm.email }}" required>
  304. </div>
  305. {% if getConfig('crowi', 'security:registrationWhiteList') && getConfig('crowi', 'security:registrationWhiteList').length %}
  306. <p class="form-text">
  307. {{ t('page_register.form_help.email') }}
  308. </p>
  309. <ul>
  310. {% for em in getConfig('crowi', 'security:registrationWhiteList') %}
  311. <li><code>{{ em }}</code></li>
  312. {% endfor %}
  313. </ul>
  314. {% endif %}
  315. <div class="input-group">
  316. <div class="input-group-prepend">
  317. <span class="input-group-text"><i class="icon-lock"></i></span>
  318. </div>
  319. <input type="password" class="form-control" placeholder="{{ t('Password') }}" name="registerForm[password]" required>
  320. </div>
  321. <div class="input-group justify-content-center mt-5">
  322. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  323. <button type="submit" class="btn btn-fill px-0 py-2" id="register">
  324. <div class="eff"></div>
  325. <span class="btn-label p-3"><i class="icon-user-follow"></i></span>
  326. <span class="btn-label-text p-3">{{ t('Sign up') }}</span>
  327. </button>
  328. </div>
  329. </form>
  330. <div class="border-bottom mb-3"></div>
  331. <div class="row">
  332. <div class="text-right col-12 py-1">
  333. <a href="#login" id="login" class="link-switch">
  334. <i class="icon-fw icon-login"></i>{{ t('Sign in is here') }}
  335. </a>
  336. </div>
  337. </div>
  338. </div>
  339. {% endif %} {# if isRegistrationEnabled id false #}
  340. </div>
  341. <a href="https://growi.org" class="link-growi-org pl-3">
  342. <span class="growi">GROWI</span>.<span class="org">ORG
  343. </a>
  344. </div>
  345. </div>
  346. </div>
  347. </div>
  348. {% endblock %}
  349. {% block body_end %}
  350. <script>
  351. // login
  352. $('#register').on('click', function() {
  353. $('#login-dialog').addClass('to-flip');
  354. return false;
  355. });
  356. $('#login').on('click', function() {
  357. $('#login-dialog').removeClass('to-flip');
  358. return false;
  359. });
  360. $('#register-form input[name="registerForm[username]"]').change(function(e) {
  361. var username = $(this).val();
  362. $('#login-dialog').removeClass('has-error');
  363. $('#input-group-username').removeClass('has-error');
  364. $('#help-block-username').html("");
  365. $.getJSON('/_api/check_username', {username: username}, function(json) {
  366. if (!json.valid) {
  367. $('#help-block-username').html(
  368. '<i class="icon-fw icon-ban"></i> This User ID is not available.'
  369. );
  370. $('#login-dialog').addClass('has-error');
  371. $('#input-group-username').addClass('has-error');
  372. }
  373. });
  374. });
  375. </script>
  376. {% endblock %}