Start login template refactor

This commit is contained in:
Sonny Bakker 2021-08-29 22:43:11 +02:00
parent 7504acced2
commit 1087ce4a3c
3 changed files with 71 additions and 8 deletions

View file

@ -1,17 +1,78 @@
{% extends "components/form/form.html" %} {% extends "components/form/form.html" %}
{% load i18n %} {% load i18n %}
{# TODO incorporate formtools wizard #}
{# TODO add support for other devices and backup tokens #}
{# see two_factor/templates/two_factor/core/login.html #}
{% block intro %}
<div class="form__intro">
{% if wizard.steps.current == 'auth' %}
<p>{% blocktrans %}Enter your credentials.{% endblocktrans %}</p>
{% elif wizard.steps.current == 'token' %}
{% if device.method == 'call' %}
<p>
{% blocktrans trimmed %}
We are calling your phone right now, please enter the digits you hear.
{% endblocktrans %}
</p>
{% elif device.method == 'sms' %}
<p>
{% blocktrans trimmed %}
We sent you a text message, please enter the tokens we sent.
{% endblocktrans %}
</p>
{% else %}
<p>
{% blocktrans trimmed %}
Please enter the tokens generated by your token generator.
{% endblocktrans %}
</p>
{% endif %}
{% elif wizard.steps.current == 'backup' %}
<p>
{% blocktrans trimmed %}
Use this form for entering backup tokens for logging in.
These tokens have been generated for you to print and keep safe. Please
enter one of these backup tokens to login to your account.
{% endblocktrans %}
</p>
{% endif %}
</div>
{% endblock intro %}
{# TODO test this #}
{% block fields %}
{{ wizard.management_form }}
{{ block.super }}
{% endblock fields %}
{% block actions %} {% block actions %}
<section class="section form__section--last"> <section class="section form__section--last">
<fieldset class="fieldset form__fieldset"> <fieldset class="fieldset form__fieldset">
{% include "components/form/cancel-button.html" %} {% if cancel_url %}
{% include "components/form/cancel-button.html" %}
{% endif %}
{% if wizard.steps.prev %}
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}" class="link button">
{% trans "Back" %}
</button>
{% else %}
<button disabled name="" type="button" class="link button">
{% trans "Back" %}
</button>
{% endif %}
{% include "components/form/confirm-button.html" %} {% include "components/form/confirm-button.html" %}
</fieldset> </fieldset>
<fieldset class="fieldset form__fieldset"> {% if wizard.steps.index == wizard.steps.first %}
<a class="link" href="{% url 'accounts:password-reset' %}"> <fieldset class="fieldset form__fieldset">
<small class="small">{% trans "I forgot my password" %}</small> <a class="link" href="{% url 'accounts:password-reset' %}">
</a> <small class="small">{% trans "I forgot my password" %}</small>
</fieldset> </a>
</fieldset>
{% endif %}
</section> </section>
{% endblock actions %} {% endblock actions %}

View file

@ -2,6 +2,6 @@
{% block content %} {% block content %}
<main id="login--page" class="main"> <main id="login--page" class="main">
{% include "accounts/components/login-form.html" with form=form title="Login" confirm_text="Login" %} {% include "accounts/components/login-form.html" with title="Login" confirm_text="Next" %}
</main> </main>
{% endblock %} {% endblock %}

View file

@ -1,8 +1,10 @@
from django.contrib.auth import views as django_views from django.contrib.auth import views as django_views
from django.urls import reverse_lazy from django.urls import reverse_lazy
from two_factor import views as two_factor_views
class LoginView(django_views.LoginView):
class LoginView(two_factor_views.LoginView):
template_name = "accounts/views/login.html" template_name = "accounts/views/login.html"
success_url = reverse_lazy("index") success_url = reverse_lazy("index")