From 9bf0849b920a08b7f4bf97dec4f673e4e807e55f Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Fri, 13 Dec 2024 20:21:44 -0500 Subject: [PATCH] Add multi-factor authentication (MFA) support; update localization and error handling --- backend/server/requirements.txt | 1 + frontend/src/lib/components/TOTPModal.svelte | 31 +++++-------- frontend/src/locales/de.json | 46 +++++++++++++++++-- frontend/src/locales/en.json | 20 +++++++- frontend/src/locales/es.json | 24 +++++++++- frontend/src/locales/fr.json | 46 +++++++++++++++++-- frontend/src/locales/it.json | 46 +++++++++++++++++-- frontend/src/locales/nl.json | 46 +++++++++++++++++-- frontend/src/locales/pl.json | 46 +++++++++++++++++-- frontend/src/locales/sv.json | 46 +++++++++++++++++-- frontend/src/locales/zh.json | 46 +++++++++++++++++-- frontend/src/routes/login/+page.server.ts | 6 +-- frontend/src/routes/login/+page.svelte | 2 +- frontend/src/routes/settings/+page.svelte | 22 +++++---- .../user/verify-email/[key]/+page.svelte | 9 ++-- 15 files changed, 369 insertions(+), 68 deletions(-) diff --git a/backend/server/requirements.txt b/backend/server/requirements.txt index 5e2d10a..3f6b406 100644 --- a/backend/server/requirements.txt +++ b/backend/server/requirements.txt @@ -12,6 +12,7 @@ django-resized django-geojson setuptools gunicorn==23.0.0 +qrcode==8.0 # slippers==0.6.2 # django-allauth-ui==1.5.1 # django-widget-tweaks==1.5.0 \ No newline at end of file diff --git a/frontend/src/lib/components/TOTPModal.svelte b/frontend/src/lib/components/TOTPModal.svelte index 68b24bd..77da717 100644 --- a/frontend/src/lib/components/TOTPModal.svelte +++ b/frontend/src/lib/components/TOTPModal.svelte @@ -53,18 +53,10 @@ } async function sendTotp() { - console.log('sending totp'); - - let sessionid = document.cookie - .split('; ') - .find((row) => row.startsWith('sessionid')) - ?.split('=')[1]; - const res = await fetch('/_allauth/browser/v1/account/authenticators/totp', { method: 'POST', headers: { - 'Content-Type': 'application/json', - Cookie: `sessionid=${sessionid}` + 'Content-Type': 'application/json' }, body: JSON.stringify({ code: first_code @@ -73,7 +65,7 @@ }); console.log(res); if (res.ok) { - addToast('success', '2FA enabled'); + addToast('success', $t('settings.mfa_enabled')); is_enabled = true; getRecoveryCodes(); } else { @@ -125,10 +117,10 @@