Style every MFA screen through the element system

The MFA pages (manage, TOTP activate/deactivate, recovery codes, security keys,
reauthenticate) are built almost entirely from allauth's `element` primitives, so
they are styled by overriding the elements rather than by rewriting eight page
templates. New allauth pages then inherit the look for free.

- field + img elements were missing entirely, so allauth fell back to bare HTML:
  the TOTP secret and recovery-code list rendered as unstyled inputs. The QR now
  sits on a white plate -- it is dark modules on a transparent ground, so on the
  dark theme it was dark-on-dark and phones could not scan it.
- button now honours the tags allauth sets. They were all flattened to
  btn-primary, which made "Deactivate" look exactly as safe as "View".
- the `code` field renders as a daisyUI otp wherever it appears, so the
  reauthenticate and activate pages get the same input as the login challenge.
  The boxes step aside past six characters: allauth accepts a TOTP code (6) or a
  recovery code (8) in that one field.

Fixes a crash: the security-key list does {% load humanize %}, which raised
TemplateSyntaxError because django.contrib.humanize was not installed. That page
500'd on every request; it is now installed and covered by a test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-13 23:07:44 +02:00
parent 2b7b2b64db
commit addfc61a2c
10 changed files with 196 additions and 49 deletions

View File

@@ -7,6 +7,7 @@
--font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
--color-sky-500: oklch(68.5% 0.169 237.323);
--color-black: #000;
--color-white: #fff;
--spacing: 0.25rem;
--container-xs: 20rem;
--container-xl: 36rem;
@@ -3089,6 +3090,9 @@
.bg-primary {
background-color: var(--color-primary);
}
.bg-white {
background-color: var(--color-white);
}
.btn-link {
@layer daisyui {
text-decoration-line: underline;
@@ -3119,6 +3123,17 @@
background-image: none;
}
}
.btn-outline {
@layer daisyui.l1.l2.l3 {
--btn-bg: #0000;
color: var(--btn-rest-fg, var(--btn-color, var(--color-base-content)));
--btn-border: var(--btn-color, var(--color-base-content));
--btn-border-style: solid;
background-image: none;
--btn-inset: 0 0 0 0 oklch(0% 0 0/0);
--btn-shadow: 0 0 0 0 oklch(0% 0 0/0);
}
}
.btn-ghost {
@layer daisyui.l1.l2.l3 {
--btn-bg: #0000;
@@ -3135,6 +3150,9 @@
.p-2 {
padding: calc(var(--spacing) * 2);
}
.p-3 {
padding: calc(var(--spacing) * 3);
}
.p-4 {
padding: calc(var(--spacing) * 4);
}
@@ -3352,6 +3370,14 @@
}
}
}
.btn-neutral {
@layer daisyui.l1.l2 {
--btn-color: var(--color-neutral);
--btn-fg: var(--color-neutral-content);
--btn-soft-bg: var(--color-neutral-content) 80%;
--btn-rest-fg: initial;
}
}
.btn-accent {
@layer daisyui.l1.l2 {
--btn-color: var(--color-accent);