diff --git a/package.json b/package.json index 7190e4e1..11afaa5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "photon-lemmy", - "version": "1.13.5", + "version": "1.14.0", "private": true, "scripts": { "dev": "vite dev", diff --git a/src/routes/profile/(local_user)/password/+page.svelte b/src/routes/profile/(local_user)/password/+page.svelte index f92b9ed1..b7c10194 100644 --- a/src/routes/profile/(local_user)/password/+page.svelte +++ b/src/routes/profile/(local_user)/password/+page.svelte @@ -2,15 +2,22 @@ import { deleteProfile, profile, setUser } from '$lib/auth.js' import { getClient } from '$lib/lemmy.js' import { trycatch } from '$lib/util.js' - import { Button, TextInput, toast } from 'mono-svelte' + import { Button, Snippet, TextInput, toast } from 'mono-svelte' import { instance as currentInstance } from '$lib/instance.js' + import { ClipboardDocument, Icon } from 'svelte-hero-icons' + import { goto } from '$app/navigation' + import { page } from '$app/stores' + + export let data let oldPassword = '', newPassword = '', newPasswordVerify = '' let loading = false - async function submit() { + $: totpLink = data.my_user?.local_user_view?.local_user?.totp_2fa_url + + async function changePassword() { try { if (!$profile?.jwt) return loading = true @@ -41,29 +48,88 @@ loading = false } + + async function twofa(enabled: boolean) { + if (!$profile?.jwt) return + + try { + await getClient().saveUserSettings({ + ...data.my_user?.local_user_view.local_user, + ...data.my_user?.local_user_view.person, + generate_totp_2fa: enabled, + auth: $profile?.jwt, + }) + goto($page.url, { invalidateAll: true }) + toast({ + content: `Successfully ${enabled ? 'enabled' : 'disabled'} 2FA.`, + type: 'success', + }) + } catch (e) { + toast({ content: e as any, type: 'error' }) + } + } -
+ 2FA on Lemmy is unstable and you may lock yourself out of your account. +
+ {#if totpLink} +