login-form.html.twig 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. {% set client_side_validation = form.client_side_validation is not null ? form.client_side_validation : config.plugins.form.client_side_validation|default(true) %}
  2. {% set inline_errors = form.inline_errors is not null ? form.inline_errors : config.plugins.form.inline_errors(false) %}
  3. <section id="grav-login">
  4. {% if page.template == 'login' or show_login_form %}
  5. {% set user = grav.user %}
  6. {% if user.authenticated and user.authorized %}
  7. <h4>{{ 'PLUGIN_LOGIN.WELCOME'|t }} <strong>{{ user.fullname ?: user.username }}</strong></h4>
  8. <hr>
  9. <a class="button logout" href="{{ uri.addNonce(base_url_relative ~ uri.path ~ '/task' ~ config.system.param_sep ~ 'login.logout', 'logout-form', 'logout-nonce')|e }}">{{ 'PLUGIN_LOGIN.BTN_LOGOUT'|t }}</a>
  10. {% elseif user.authenticated and user.twofa_enabled %}
  11. {% include 'partials/login-twofa.html.twig' %}
  12. {% else %}
  13. {{ content|raw }}
  14. {# NEW WAY OF INCLUDING 3RD PARTY LOGIN OPTIONS #}
  15. {% for template in grav.login.getProviderLoginTemplates %}
  16. {% include template %}
  17. {% endfor %}
  18. <form method="post" action="{{ (base_url_relative ~ uri.path)|e }}" class="{{ form_outer_classes }}">
  19. {# OLD WAY OF INCLUDING 3RD PARTY LOGIN OPTIONS #}
  20. {% if grav.twig.plugins_hooked_loginPage %}
  21. {% for label in grav.twig.plugins_hooked_loginPage %}
  22. {% include label %}
  23. {% endfor %}
  24. {% endif %}
  25. {% for field in form.fields %}
  26. {% set value = field.name == 'username' ? username : '' %}
  27. {% if field.type %}
  28. {% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
  29. {% endif %}
  30. {% endfor %}
  31. <div class="{{ form_button_outer_classes ?: 'form-actions secondary-accent' }}">
  32. {% if config.plugins.login.rememberme.enabled and page.header.form.login.rememberme ?? true %}
  33. <div class="form-data rememberme" data-grav-default="null" data-grav-disabled="true" data-grav-field="checkbox">
  34. <div class="form-input-wrapper">
  35. <input type="checkbox" value="1" name="rememberme" id="#rememberme">
  36. <label class="inline" for="#rememberme" title="{{ 'PLUGIN_LOGIN.REMEMBER_ME_HELP'|t }}">{{ 'PLUGIN_LOGIN.REMEMBER_ME'|t }}</label>
  37. </div>
  38. </div>
  39. {% endif %}
  40. {% if page.header.form.login.forgot_button ?? true %}
  41. <a class="{{ form_button_classes ?: 'button secondary' }}" href="{{ base_url_relative }}{{ config.plugins.login.route_forgot }}"><i class="fa fa-exclamation-circle"></i> {{ 'PLUGIN_LOGIN.BTN_FORGOT'|t }}</a>
  42. {% endif %}
  43. <button class="{{ form_button_classes ?: 'button primary' }}" type="submit" name="task" value="login.login"><i class="fa fa-sign-in"></i> {{ 'PLUGIN_LOGIN.BTN_LOGIN'|t }}</button>
  44. </div>
  45. {{ nonce_field('login-form', 'login-form-nonce')|raw }}
  46. </form>
  47. {% endif %}
  48. {% endif %}
  49. </section>