diff --git a/src/lib/components/input/Switch.svelte b/src/lib/components/input/Switch.svelte
index f85c01af..0ef326e7 100644
--- a/src/lib/components/input/Switch.svelte
+++ b/src/lib/components/input/Switch.svelte
@@ -1,4 +1,6 @@
+
+
+ {@render children?.()}
+
diff --git a/src/lib/components/ui/Placeholder.svelte b/src/lib/components/ui/Placeholder.svelte
index c10271f8..36755214 100644
--- a/src/lib/components/ui/Placeholder.svelte
+++ b/src/lib/components/ui/Placeholder.svelte
@@ -1,12 +1,14 @@
@@ -24,7 +27,12 @@
{#if icon}
diff --git a/src/lib/components/ui/layout/pages/Tabs.svelte b/src/lib/components/ui/layout/pages/Tabs.svelte
index 6be07a72..f9329acc 100644
--- a/src/lib/components/ui/layout/pages/Tabs.svelte
+++ b/src/lib/components/ui/layout/pages/Tabs.svelte
@@ -1,6 +1,7 @@
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index cac43dd0..82e026e4 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -162,7 +162,8 @@
"2fa": {
"totp": "TOTP",
"2fa": "2FA",
- "paste": "Paste this in your authenticator app."
+ "paste": "Paste this in your authenticator app.",
+ "disabled": "2FA is disabled"
},
"deleteAccount": {
"label": "Delete account",
@@ -172,6 +173,10 @@
"languages": {
"title": "Languages",
"description": "If any are set, you will only see content explicitly tagged as that language. Most content, untagged, falls under 'Undetermined'."
+ },
+ "credentials": {
+ "title": "Manage how you log in",
+ "description": "You can enable 2FA for greater security, change your password, view logged in devices, or delete your account here."
}
},
"email": "Email",
diff --git a/src/routes/profile/(local_user)/password/+layout.svelte b/src/routes/profile/(local_user)/password/+layout.svelte
index a65d6b4c..09bdc155 100644
--- a/src/routes/profile/(local_user)/password/+layout.svelte
+++ b/src/routes/profile/(local_user)/password/+layout.svelte
@@ -3,7 +3,7 @@
import { page } from '$app/state'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
- import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
+ import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
/**
* @typedef {Object} Props
* @property {import('svelte').Snippet} [children]
@@ -13,46 +13,36 @@
let { children } = $props()
const routes = [
- {
- name: $t('routes.profile.credentials'),
- url: '/profile/password',
- },
{
name: $t('form.profile.2fa.2fa'),
- url: '/profile/password/2fa',
+ href: '/profile/password/2fa',
},
{
name: $t('routes.passwordChange.title'),
- url: '/profile/password/change',
+ href: '/profile/password/change',
},
{
name: $t('routes.profile.logins'),
- url: '/profile/password/logins',
+ href: '/profile/password/logins',
},
{
name: $t('routes.profile.delete.title'),
- url: '/profile/password/delete',
+ href: '/profile/password/delete',
},
]
- {routes.find(r => page.url.pathname == r.url)?.name}
+ {routes.find(r => page.url.pathname == r.href)?.name ??
+ $t('routes.profile.credentials')}
-
-
-
- {@render children?.()}
-
+
+
+
+ {@render children?.()}
diff --git a/src/routes/profile/(local_user)/password/+page.svelte b/src/routes/profile/(local_user)/password/+page.svelte
index aec00da8..5c1619c4 100644
--- a/src/routes/profile/(local_user)/password/+page.svelte
+++ b/src/routes/profile/(local_user)/password/+page.svelte
@@ -1,103 +1,13 @@
-
diff --git a/src/routes/profile/(local_user)/password/2fa/+page.svelte b/src/routes/profile/(local_user)/password/2fa/+page.svelte
index a1182cf3..1bb9e5e0 100644
--- a/src/routes/profile/(local_user)/password/2fa/+page.svelte
+++ b/src/routes/profile/(local_user)/password/2fa/+page.svelte
@@ -4,9 +4,10 @@
import { client } from '$lib/lemmy.svelte.js'
import { t } from '$lib/i18n/translations.js'
import { qr } from '@svelte-put/qr/svg'
- import { Button, Material, TextInput, toast } from 'mono-svelte'
- import { ClipboardDocument, Icon } from 'svelte-hero-icons'
+ import { Button, Material, Modal, TextInput, toast } from 'mono-svelte'
+ import { ClipboardDocument, Icon, Key } from 'svelte-hero-icons'
import { errorMessage } from '$lib/lemmy/error.js'
+ import Placeholder from '$lib/components/ui/Placeholder.svelte'
let { data } = $props()
@@ -17,8 +18,18 @@
let verify_totp = $state('')
+ let openModal = $state(false)
+ $effect(() => {
+ if (!openModal) totpLink = undefined
+ })
+
async function twofa(enabled: boolean, update: boolean = false) {
try {
+ if (!enabled && !update) {
+ openModal = true
+ return
+ }
+
if (update) {
await client().updateTotp({
enabled: enabled,
@@ -34,24 +45,23 @@
} else {
const res = await client().generateTotpSecret()
totpLink = res.totp_secret_url
- totpEnabled = true
+ openModal = true
}
- } catch (e) {
- toast({ content: errorMessage(e as string), type: 'error' })
+ } catch (err) {
+ toast({ content: errorMessage(err as string), type: 'error' })
}
}
-
-
-
- {totpEnabled ? $t('common.enabled') : $t('common.disabled')}
-
-
- {#if totpEnabled || totpLink}
+
+
{#if totpLink && !totpEnabled}
-
-
+
+
{/if}
-
- {:else}
-
- {/if}
+
+
+ {#if totpEnabled}
+
+
+
+ {:else}
+
+
+
+ {/if}
+
diff --git a/src/routes/profile/(local_user)/password/change/+page.svelte b/src/routes/profile/(local_user)/password/change/+page.svelte
index c51bf28f..c1c7cc36 100644
--- a/src/routes/profile/(local_user)/password/change/+page.svelte
+++ b/src/routes/profile/(local_user)/password/change/+page.svelte
@@ -1,11 +1,9 @@
-