From 1de780729d03ca06c451e51f5dcc5b7bdc5af5bb Mon Sep 17 00:00:00 2001 From: Yuval Hager Date: Mon, 10 Feb 2025 23:27:50 -0800 Subject: [PATCH 1/2] add templates for request and confirm login code --- .../templates/account/confirm_login_code.html | 37 +++++++++++++++++++ .../templates/account/request_login_code.html | 17 +++++++++ tests/settings.py | 1 + 3 files changed, 55 insertions(+) create mode 100644 allauth_ui/templates/account/confirm_login_code.html create mode 100644 allauth_ui/templates/account/request_login_code.html diff --git a/allauth_ui/templates/account/confirm_login_code.html b/allauth_ui/templates/account/confirm_login_code.html new file mode 100644 index 0000000..c038ac4 --- /dev/null +++ b/allauth_ui/templates/account/confirm_login_code.html @@ -0,0 +1,37 @@ +{# -*- engine:django -*- #} +{% extends "account/confirm_login_code.html" %} + +{% load i18n %} +{% load allauth %} +{% load allauth_ui %} +{% load widget_tweaks %} +{% block content %} + +{% trans "Sign In" as heading %} +{% #container heading=heading %} +
+ {% blocktranslate %}Enter Sign-In Code{% endblocktranslate %} +
+
+ {% setvar email_link %} + {{ email }} + {% endsetvar %} + {% blocktranslate %}We’ve sent a code to {{ email_link }}. The code expires shortly, so please enter it soon.{% endblocktranslate %} +
+{% url 'account_confirm_login_code' as action_url %} +{% #form form=form url=action_url button_text=heading %} +{{ redirect_field }} +{% csrf_token %} +{% /form %} + +
+ + {% csrf_token %} +
+{% /container %} +{% endblock content %} +{% comment %}{% endcomment %} diff --git a/allauth_ui/templates/account/request_login_code.html b/allauth_ui/templates/account/request_login_code.html new file mode 100644 index 0000000..ec92744 --- /dev/null +++ b/allauth_ui/templates/account/request_login_code.html @@ -0,0 +1,17 @@ +{% extends "account/request_login_code.html" %} +{% load i18n %} +{% load allauth_ui %} +{% load widget_tweaks %} +{% block content %} +{% trans "Mail me a sign-in code" as heading %} +{% #container heading=heading %} +
+ {% blocktranslate %}You will receive an email containing a special code for a password-free sign-in.{% endblocktranslate %} +
+{% url 'account_request_login_code' as action_url %} +{% #form form=form url=action_url button_text=heading %} +{{ redirect_field }} +{% csrf_token %} +{% /form %} +{% /container %} +{% endblock content %} diff --git a/tests/settings.py b/tests/settings.py index 1a585a9..5ce28d9 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -111,6 +111,7 @@ ACCOUNT_EMAIL_VERIFICATION = "mandatory" ACCOUNT_AUTHENTICATION_METHOD = "email" ACCOUNT_LOGIN_ATTEMPTS_LIMIT = 1000 +ACCOUNT_LOGIN_BY_CODE_ENABLED = "true" BASE_DIR = Path(__file__).parent.parent From 2e231add93ba9d5e6b09c3148b4d0d270354b06d Mon Sep 17 00:00:00 2001 From: Yuval Hager Date: Tue, 11 Feb 2025 12:18:35 -0800 Subject: [PATCH 2/2] djlint reformat --- .../templates/account/confirm_login_code.html | 20 ++++++----------- .../templates/account/request_login_code.html | 22 +++++++++---------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/allauth_ui/templates/account/confirm_login_code.html b/allauth_ui/templates/account/confirm_login_code.html index c038ac4..4d78330 100644 --- a/allauth_ui/templates/account/confirm_login_code.html +++ b/allauth_ui/templates/account/confirm_login_code.html @@ -1,20 +1,16 @@ {# -*- engine:django -*- #} {% extends "account/confirm_login_code.html" %} - {% load i18n %} {% load allauth %} {% load allauth_ui %} {% load widget_tweaks %} {% block content %} - -{% trans "Sign In" as heading %} -{% #container heading=heading %} -
- {% blocktranslate %}Enter Sign-In Code{% endblocktranslate %} -
-
- {% setvar email_link %} - {{ email }} + {% trans "Sign In" as heading %} + {% #container heading=heading %} +
{% blocktranslate %}Enter Sign-In Code{% endblocktranslate %}
+
+ {% setvar email_link %} + {{ email }} {% endsetvar %} {% blocktranslate %}We’ve sent a code to {{ email_link }}. The code expires shortly, so please enter it soon.{% endblocktranslate %}
@@ -23,9 +19,7 @@ {{ redirect_field }} {% csrf_token %} {% /form %} - +
diff --git a/allauth_ui/templates/account/request_login_code.html b/allauth_ui/templates/account/request_login_code.html index ec92744..2b84487 100644 --- a/allauth_ui/templates/account/request_login_code.html +++ b/allauth_ui/templates/account/request_login_code.html @@ -3,15 +3,15 @@ {% load allauth_ui %} {% load widget_tweaks %} {% block content %} -{% trans "Mail me a sign-in code" as heading %} -{% #container heading=heading %} -
- {% blocktranslate %}You will receive an email containing a special code for a password-free sign-in.{% endblocktranslate %} -
-{% url 'account_request_login_code' as action_url %} -{% #form form=form url=action_url button_text=heading %} -{{ redirect_field }} -{% csrf_token %} -{% /form %} -{% /container %} + {% trans "Mail me a sign-in code" as heading %} + {% #container heading=heading %} +
+ {% blocktranslate %}You will receive an email containing a special code for a password-free sign-in.{% endblocktranslate %} +
+ {% url 'account_request_login_code' as action_url %} + {% #form form=form url=action_url button_text=heading %} + {{ redirect_field }} + {% csrf_token %} + {% /form %} + {% /container %} {% endblock content %}