Sync shared snapshot from e8a9b25
Docker / Docker Build & Push (push) Successful in 4m53s

This commit is contained in:
Gabriel20xx committed 2026-08-23 22:19:15 +02:00
1 parent 4a37006069
commit c4b40a9c36
1 file changed
+16 -11
@@ -50,6 +50,11 @@
let resetOpen = $state(false); let resetOpen = $state(false);
let resetting = $state(false); let resetting = $state(false);
// A failed status fetch tells us nothing about whether setup is actually required —
// defaulting to the setup view in that case would wrongly invite creating a new
// account when the real problem is that the server couldn't be reached.
let effectiveSetupRequired = $derived(error ? false : setupRequired);
function isTotpChallenge(caught: unknown): boolean { function isTotpChallenge(caught: unknown): boolean {
if (!(caught instanceof Error)) return false; if (!(caught instanceof Error)) return false;
const message = caught.message.toLowerCase(); const message = caught.message.toLowerCase();
@@ -65,7 +70,7 @@
event.preventDefault(); event.preventDefault();
submitError = ''; submitError = '';
if (setupRequired && password !== confirmPassword) { if (effectiveSetupRequired && password !== confirmPassword) {
submitError = 'Passwords do not match.'; submitError = 'Passwords do not match.';
return; return;
} }
@@ -73,7 +78,7 @@
submitting = true; submitting = true;
try { try {
if (setupRequired) { if (effectiveSetupRequired) {
if (!onSetup) throw new Error('The application has not configured its setup handler.'); if (!onSetup) throw new Error('The application has not configured its setup handler.');
await onSetup({ username, email, password }); await onSetup({ username, email, password });
} else { } else {
@@ -85,11 +90,11 @@
await onLogin({ identifier, password, totpToken: totpToken.trim() }); await onLogin({ identifier, password, totpToken: totpToken.trim() });
} }
} catch (caught) { } catch (caught) {
if (!setupRequired && showTotp && isTotpChallenge(caught)) { if (!effectiveSetupRequired && showTotp && isTotpChallenge(caught)) {
totpRequired = true; totpRequired = true;
submitError = 'Enter the six-digit authenticator code to continue.'; submitError = 'Enter the six-digit authenticator code to continue.';
} else { } else {
if (!setupRequired) { if (!effectiveSetupRequired) {
totpRequired = false; totpRequired = false;
totpToken = ''; totpToken = '';
} }
@@ -143,7 +148,7 @@
{#if loading} {#if loading}
<h1 id="sc-auth-title">Loading...</h1> <h1 id="sc-auth-title">Loading...</h1>
{:else} {:else}
<h1 id="sc-auth-title">{setupRequired ? 'Create your account' : 'Welcome back'}</h1> <h1 id="sc-auth-title">{effectiveSetupRequired ? 'Create your account' : 'Welcome back'}</h1>
{/if} {/if}
{#if !loading} {#if !loading}
{#if tagline} {#if tagline}
@@ -151,7 +156,7 @@
{/if} {/if}
<form class="sc-form sc-auth-form" onsubmit={submit}> <form class="sc-form sc-auth-form" onsubmit={submit}>
{#if setupRequired} {#if effectiveSetupRequired}
<label class="sc-field"> <label class="sc-field">
<span class="sc-label">Username</span> <span class="sc-label">Username</span>
<input <input
@@ -192,7 +197,7 @@
<label class="sc-field"> <label class="sc-field">
<span class="sc-label">Password</span> <span class="sc-label">Password</span>
<input <input
autocomplete={setupRequired ? 'new-password' : 'current-password'} autocomplete={effectiveSetupRequired ? 'new-password' : 'current-password'}
class="sc-input" class="sc-input"
minlength="8" minlength="8"
name="password" name="password"
@@ -202,7 +207,7 @@
/> />
</label> </label>
{#if showTotp && !setupRequired && totpRequired} {#if showTotp && !effectiveSetupRequired && totpRequired}
<label class="sc-field"> <label class="sc-field">
<span class="sc-label">Authenticator code</span> <span class="sc-label">Authenticator code</span>
<input <input
@@ -216,7 +221,7 @@
</label> </label>
{/if} {/if}
{#if setupRequired} {#if effectiveSetupRequired}
<label class="sc-field"> <label class="sc-field">
<span class="sc-label">Confirm password</span> <span class="sc-label">Confirm password</span>
<input <input
@@ -236,7 +241,7 @@
{/if} {/if}
<Button disabled={loading || submitting} fullWidth size="lg" type="submit"> <Button disabled={loading || submitting} fullWidth size="lg" type="submit">
{loading || submitting ? 'Please wait…' : setupRequired ? 'Create account' : 'Log in'} {loading || submitting ? 'Please wait…' : effectiveSetupRequired ? 'Create account' : 'Log in'}
</Button> </Button>
</form> </form>
@@ -244,7 +249,7 @@
<div class="sc-auth-extra">{@render children()}</div> <div class="sc-auth-extra">{@render children()}</div>
{/if} {/if}
{#if !setupRequired && onRequestReset && onConfirmReset} {#if !effectiveSetupRequired && onRequestReset && onConfirmReset}
{#if resetOpen} {#if resetOpen}
<div class="sc-auth-reset" aria-live="polite"> <div class="sc-auth-reset" aria-live="polite">
<p class="sc-auth-reset-hint">A reset code has been printed to the server console.</p> <p class="sc-auth-reset-hint">A reset code has been printed to the server console.</p>