diff --git a/src/lib/version.ts b/src/lib/version.ts index 933528fa..c7ac6514 100644 --- a/src/lib/version.ts +++ b/src/lib/version.ts @@ -16,7 +16,7 @@ type Feature = keyof typeof FEATURES export const feature = (feature: Feature, version: string = '0.0.0'): boolean => versionIsSupported(version, FEATURES[feature]) -export const MINIMUM_VERSION = '0.18.1' +export const MINIMUM_VERSION = '0.19.0' export const MAXIMUM_VERSION = '0.999' export const versionIsSupported = (v: string, minimum: string) => { diff --git a/src/routes/profile/(local_user)/password/+page.svelte b/src/routes/profile/(local_user)/password/+page.svelte index da49323a..92ccff6f 100644 --- a/src/routes/profile/(local_user)/password/+page.svelte +++ b/src/routes/profile/(local_user)/password/+page.svelte @@ -7,6 +7,7 @@ import { ClipboardDocument, Icon } from 'svelte-hero-icons' import { goto } from '$app/navigation' import { page } from '$app/stores' + import Switch from '$lib/components/input/Switch.svelte' import { feature } from '$lib/version.js' export let data @@ -58,29 +59,23 @@ if (!$profile?.jwt) return try { - if (feature('newTotp', $site?.version)) { - if (update) { - await getClient().updateTotp({ - enabled: enabled, - totp_token: verify_totp, - }) - } else { - const res = await getClient().generateTotpSecret() - totpLink = res.totp_secret_url - } - } else { - const res = await getClient().saveUserSettings({ - ...data.my_user?.local_user_view.local_user, - ...data.my_user?.local_user_view.person, - // @ts-ignore - generate_totp_2fa: enabled, + if (update) { + await getClient().updateTotp({ + enabled: enabled, + totp_token: verify_totp, }) + + toast({ + content: `2FA has been ${enabled ? 'enabled' : 'disabled'}`, + type: 'success', + }) + + goto($page.url, { invalidateAll: true }) + } else { + const res = await getClient().generateTotpSecret() + totpLink = res.totp_secret_url + totpEnabled = true } - goto($page.url, { invalidateAll: true }) - toast({ - content: `Successfully ${enabled ? 'enabled' : 'disabled'} 2FA.`, - type: 'success', - }) } catch (e) { toast({ content: e as any, type: 'error' }) } @@ -118,19 +113,15 @@ -
+

2FA

- 2FA on Lemmy is unstable and you may lock yourself out of your account. - {#if feature('newTotp', $site?.version)} - - You cannot disable 2FA if you lose access to your authenticator. - - {/if} + 2FA is + {totpEnabled ? 'enabled' : 'disabled'} +

- {#if totpEnabled} - - {#if totpLink} + {#if totpEnabled || totpLink} + {#if totpLink && !totpEnabled}