mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-12 05:44:00 +00:00
feat: hide alternative sign in methods page if email login disabled
This commit is contained in:
@@ -75,6 +75,7 @@
|
|||||||
"use_your_passkey_instead": "Use your passkey instead?",
|
"use_your_passkey_instead": "Use your passkey instead?",
|
||||||
"email_login": "Email Login",
|
"email_login": "Email Login",
|
||||||
"enter_a_login_code_to_sign_in": "Enter a login code to sign in.",
|
"enter_a_login_code_to_sign_in": "Enter a login code to sign in.",
|
||||||
|
"sign_in_with_login_code": "Sign in with login code",
|
||||||
"request_a_login_code_via_email": "Request a login code via email.",
|
"request_a_login_code_via_email": "Request a login code via email.",
|
||||||
"go_back": "Go back",
|
"go_back": "Go back",
|
||||||
"an_email_has_been_sent_to_the_provided_email_if_it_exists_in_the_system": "An email has been sent to the provided email, if it exists in the system.",
|
"an_email_has_been_sent_to_the_provided_email_if_it_exists_in_the_system": "An email has been sent to the provided email, if it exists in the system.",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
import { m } from '$lib/paraglide/messages';
|
import { m } from '$lib/paraglide/messages';
|
||||||
|
import appConfigStore from '$lib/stores/application-configuration-store';
|
||||||
import { cachedBackgroundImage } from '$lib/utils/cached-image-util';
|
import { cachedBackgroundImage } from '$lib/utils/cached-image-util';
|
||||||
import { cn } from '$lib/utils/style';
|
import { cn } from '$lib/utils/style';
|
||||||
import type { Snippet } from 'svelte';
|
import type { Snippet } from 'svelte';
|
||||||
@@ -18,6 +19,24 @@
|
|||||||
} = $props();
|
} = $props();
|
||||||
|
|
||||||
const isDesktop = new MediaQuery('min-width: 1024px');
|
const isDesktop = new MediaQuery('min-width: 1024px');
|
||||||
|
let alternativeSignInButton = $state({
|
||||||
|
href: '/login/alternative',
|
||||||
|
label: m.alternative_sign_in_methods()
|
||||||
|
});
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if ($appConfigStore.emailOneTimeAccessAsUnauthenticatedEnabled) {
|
||||||
|
alternativeSignInButton.href = '/login/alternative';
|
||||||
|
alternativeSignInButton.label = m.alternative_sign_in_methods();
|
||||||
|
} else {
|
||||||
|
alternativeSignInButton.href = '/login/alternative/code';
|
||||||
|
alternativeSignInButton.label = m.sign_in_with_login_code();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (page.url.pathname == '/login') {
|
||||||
|
alternativeSignInButton.href = `${alternativeSignInButton.href}?redirect=${encodeURIComponent(page.url.pathname + page.url.search)}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if isDesktop.current}
|
{#if isDesktop.current}
|
||||||
@@ -38,14 +57,10 @@
|
|||||||
style={animate ? 'animation-delay: 500ms;' : ''}
|
style={animate ? 'animation-delay: 500ms;' : ''}
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
href={page.url.pathname == '/login'
|
href={alternativeSignInButton.href}
|
||||||
? '/login/alternative'
|
|
||||||
: `/login/alternative?redirect=${encodeURIComponent(
|
|
||||||
page.url.pathname + page.url.search
|
|
||||||
)}`}
|
|
||||||
class="text-muted-foreground text-xs transition-colors hover:underline"
|
class="text-muted-foreground text-xs transition-colors hover:underline"
|
||||||
>
|
>
|
||||||
{m.alternative_sign_in_methods()}
|
{alternativeSignInButton.label}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -75,14 +90,10 @@
|
|||||||
{@render children()}
|
{@render children()}
|
||||||
{#if showAlternativeSignInMethodButton}
|
{#if showAlternativeSignInMethodButton}
|
||||||
<a
|
<a
|
||||||
href={page.url.pathname == '/login'
|
href={alternativeSignInButton.href}
|
||||||
? '/login/alternative'
|
|
||||||
: `/login/alternative?redirect=${encodeURIComponent(
|
|
||||||
page.url.pathname + page.url.search
|
|
||||||
)}`}
|
|
||||||
class="text-muted-foreground mt-7 flex justify-center text-xs transition-colors hover:underline"
|
class="text-muted-foreground mt-7 flex justify-center text-xs transition-colors hover:underline"
|
||||||
>
|
>
|
||||||
{m.alternative_sign_in_methods()}
|
{alternativeSignInButton.label}
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
</Card.CardContent>
|
</Card.CardContent>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import Input from '$lib/components/ui/input/input.svelte';
|
import Input from '$lib/components/ui/input/input.svelte';
|
||||||
import { m } from '$lib/paraglide/messages';
|
import { m } from '$lib/paraglide/messages';
|
||||||
import UserService from '$lib/services/user-service';
|
import UserService from '$lib/services/user-service';
|
||||||
|
import appConfigStore from '$lib/stores/application-configuration-store';
|
||||||
import userStore from '$lib/stores/user-store.js';
|
import userStore from '$lib/stores/user-store.js';
|
||||||
import { getAxiosErrorMessage } from '$lib/utils/error-util';
|
import { getAxiosErrorMessage } from '$lib/utils/error-util';
|
||||||
import { preventDefault } from '$lib/utils/event-util';
|
import { preventDefault } from '$lib/utils/event-util';
|
||||||
@@ -63,8 +64,12 @@
|
|||||||
<form onsubmit={preventDefault(authenticate)} class="w-full max-w-[450px]">
|
<form onsubmit={preventDefault(authenticate)} class="w-full max-w-[450px]">
|
||||||
<Input id="Code" class="mt-7" placeholder={m.code()} bind:value={code} type="text" />
|
<Input id="Code" class="mt-7" placeholder={m.code()} bind:value={code} type="text" />
|
||||||
<div class="mt-8 flex justify-between gap-2">
|
<div class="mt-8 flex justify-between gap-2">
|
||||||
<Button variant="secondary" class="flex-1" href={'/login/alternative' + page.url.search}
|
<Button
|
||||||
>{m.go_back()}</Button
|
variant="secondary"
|
||||||
|
class="flex-1"
|
||||||
|
href={($appConfigStore.emailOneTimeAccessAsUnauthenticatedEnabled
|
||||||
|
? '/login/alternative'
|
||||||
|
: '/login') + page.url.search}>{m.go_back()}</Button
|
||||||
>
|
>
|
||||||
<Button class="flex-1" type="submit" {isLoading}>{m.submit()}</Button>
|
<Button class="flex-1" type="submit" {isLoading}>{m.submit()}</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user