feat(ui): auto-confirm the email deeplink on load
CI / changes (pull_request) Successful in 1s
CI / unit (pull_request) Successful in 10s
CI / integration (pull_request) Successful in 14s
CI / ui (pull_request) Successful in 1m3s
CI / conformance (pull_request) Successful in 9s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m44s
CI / changes (pull_request) Successful in 1s
CI / unit (pull_request) Successful in 10s
CI / integration (pull_request) Successful in 14s
CI / ui (pull_request) Successful in 1m3s
CI / conformance (pull_request) Successful in 9s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m44s
Drop the confirm button: the /confirm screen confirms the token as soon as it loads. The token rides the URL fragment (never sent to the server), so a plain link prefetch cannot reach it, and the manual six-digit code is the fallback if an aggressive scanner runs the page. Update the ARCHITECTURE/FUNCTIONAL wording accordingly and swap the confirm.prompt/action strings for confirm.busy (en+ru).
This commit is contained in:
@@ -36,8 +36,7 @@ export const en = {
|
||||
'login.sendCode': 'Send code',
|
||||
'login.codePlaceholder': '6-digit code',
|
||||
'login.signIn': 'Sign in',
|
||||
'confirm.prompt': 'Confirm your email to finish.',
|
||||
'confirm.action': 'Confirm',
|
||||
'confirm.busy': 'Confirming your email…',
|
||||
'confirm.linked': 'Email confirmed.',
|
||||
'confirm.merge': 'Almost done — finish the merge in the app.',
|
||||
'confirm.close': 'You can close this window and return to the game.',
|
||||
|
||||
@@ -37,8 +37,7 @@ export const ru: Record<MessageKey, string> = {
|
||||
'login.sendCode': 'Отправить код',
|
||||
'login.codePlaceholder': 'Код из 6 цифр',
|
||||
'login.signIn': 'Войти',
|
||||
'confirm.prompt': 'Подтвердите почту, чтобы завершить.',
|
||||
'confirm.action': 'Подтвердить',
|
||||
'confirm.busy': 'Подтверждаем почту…',
|
||||
'confirm.linked': 'Почта подтверждена.',
|
||||
'confirm.merge': 'Почти готово — завершите объединение в приложении.',
|
||||
'confirm.close': 'Можно закрыть это окно и вернуться в игру.',
|
||||
|
||||
@@ -1,37 +1,35 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { confirmDeeplink } from '../lib/app.svelte';
|
||||
import { t } from '../lib/i18n/index.svelte';
|
||||
|
||||
let { token }: { token: string } = $props();
|
||||
// idle → busy → (login navigates away) | linked | merge | error. The token is
|
||||
// confirmed only on the button press (a POST), so a mail scanner prefetching the
|
||||
// link (a GET on the SPA route) never consumes it.
|
||||
let stage = $state<'idle' | 'busy' | 'linked' | 'merge' | 'error'>('idle');
|
||||
// The token rides the URL fragment (#/confirm/<token>), which is never sent to the
|
||||
// server, so a plain link prefetch cannot reach it — confirm as soon as the screen
|
||||
// loads. The manual 6-digit code in the same email is the fallback if an aggressive
|
||||
// scanner ever runs the page and consumes the single-use token first.
|
||||
let stage = $state<'busy' | 'linked' | 'merge' | 'error'>('busy');
|
||||
|
||||
async function confirm(): Promise<void> {
|
||||
onMount(async () => {
|
||||
if (!token) {
|
||||
stage = 'error';
|
||||
return;
|
||||
}
|
||||
stage = 'busy';
|
||||
try {
|
||||
// A login navigates into the app; a link stays here with a result.
|
||||
const r = await confirmDeeplink(token);
|
||||
// A login has already navigated into the app; a link stays here with a result.
|
||||
stage = r === 'merge_required' ? 'merge' : 'linked';
|
||||
} catch {
|
||||
stage = 'error';
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<main class="confirm">
|
||||
<div class="card">
|
||||
<div class="brand">{t('app.title')}</div>
|
||||
{#if stage === 'idle' || stage === 'busy'}
|
||||
<p>{t('confirm.prompt')}</p>
|
||||
<button class="primary" disabled={stage === 'busy'} onclick={confirm}>
|
||||
{t('confirm.action')}
|
||||
</button>
|
||||
{#if stage === 'busy'}
|
||||
<p class="muted">{t('confirm.busy')}</p>
|
||||
{:else if stage === 'linked'}
|
||||
<p class="ok">{t('confirm.linked')}</p>
|
||||
<p class="muted">{t('confirm.close')}</p>
|
||||
@@ -81,15 +79,4 @@
|
||||
.err {
|
||||
color: var(--danger, #c0392b);
|
||||
}
|
||||
button {
|
||||
padding: 12px;
|
||||
border-radius: var(--radius-sm);
|
||||
border: 1px solid var(--accent);
|
||||
font-weight: 600;
|
||||
background: var(--accent);
|
||||
color: var(--accent-text);
|
||||
}
|
||||
button:disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user