From 30be10f968d7ef688cd022192d5cc329f2569120 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 27 Jul 2026 00:55:41 +0200 Subject: [PATCH] feat: prevent duplicate auth form submissions while one is pending (#27416) * feat: prevent duplicate auth form submissions while one is pending When a sign in, sign up or LDAP request is slow, the auth form can be submitted again and every extra click or Enter press starts another concurrent authentication request. The form never tracked a pending state, so submitHandler dispatched a new API call on every submit event. This adds a submitting flag that makes submitHandler ignore re-entrant submits, disables both submit buttons with a dimmed style while a request is in flight and resets the flag in a finally block so the form recovers after a failed attempt. Guarding submitHandler covers button clicks and Enter key submits for sign in, sign up and LDAP alike since all of them flow through the single form submit handler. Fixes #27264 * feat: show a spinner while an auth request is pending Disabling the submit button stops a second submission but gives no positive sign that the first one is still running, so on a slow identity provider the form looks unresponsive rather than busy. Both submit buttons now render the existing Spinner next to their label while submitting is set, following the same in-button pattern used by the workspace editors. --- src/routes/auth/+page.svelte | 55 +++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/src/routes/auth/+page.svelte b/src/routes/auth/+page.svelte index 8abe66766b..76aa097d1b 100644 --- a/src/routes/auth/+page.svelte +++ b/src/routes/auth/+page.svelte @@ -42,6 +42,8 @@ let ldapUsername = ''; + let submitting = false; + const setSessionUser = async (sessionUser, redirectPath: string | null = null) => { if (sessionUser) { console.log(sessionUser); @@ -104,12 +106,21 @@ }; const submitHandler = async () => { - if (mode === 'ldap') { - await ldapSignInHandler(); - } else if (mode === 'signin') { - await signInHandler(); - } else { - await signUpHandler(); + if (submitting) { + return; + } + + submitting = true; + try { + if (mode === 'ldap') { + await ldapSignInHandler(); + } else if (mode === 'signin') { + await signInHandler(); + } else { + await signUpHandler(); + } + } finally { + submitting = false; } }; @@ -370,21 +381,37 @@ {#if $config?.features.enable_login_form || $config?.features.enable_ldap || form} {#if mode === 'ldap'} {:else} {#if $config?.features.enable_signup && !($config?.onboarding ?? false)}