login-form.html.twig 3.1 KB

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