login.html 18 KB

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