From e0a1961f3f29c1bdddca43c18030b45cf04f2f80 Mon Sep 17 00:00:00 2001 From: okxint Date: Tue, 21 Jul 2026 12:35:48 +0530 Subject: [PATCH] fix(core): prevent double-submit on login flow grant page Add isSubmitting guard to onSubmit so the button is disabled and shows a loading spinner as soon as the first submit fires. A second click while the form is in-flight is dropped via event.preventDefault(). Fixes: #62327 Assisted-by: ClaudeCode:claude-sonnet-4-6 --- core/src/views/LoginFlowGrant.vue | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/core/src/views/LoginFlowGrant.vue b/core/src/views/LoginFlowGrant.vue index b2230bf9da69c..f978c993623b6 100644 --- a/core/src/views/LoginFlowGrant.vue +++ b/core/src/views/LoginFlowGrant.vue @@ -9,7 +9,9 @@ import { loadState } from '@nextcloud/initial-state' import { t } from '@nextcloud/l10n' import { confirmPassword, isPasswordConfirmationRequired, PwdConfirmationMode } from '@nextcloud/password-confirmation' import NcButton from '@nextcloud/vue/components/NcButton' +import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon' import NcNoteCard from '@nextcloud/vue/components/NcNoteCard' +import { ref } from 'vue' import LoginFlowContainer from '../components/LoginFlow/LoginFlowContainer.vue' const { @@ -40,19 +42,31 @@ const { const requestToken = getRequestToken() +const isSubmitting = ref(false) + /** * Handle submit event to confirm password if required * * @param event - The submit event */ async function onSubmit(event: SubmitEvent) { - if (isPasswordConfirmationRequired(PwdConfirmationMode.Lax)) { + if (isSubmitting.value) { event.preventDefault() - event.stopPropagation() + return + } + + isSubmitting.value = true + try { + if (isPasswordConfirmationRequired(PwdConfirmationMode.Lax)) { + event.preventDefault() + event.stopPropagation() - await confirmPassword() - ;(event.target as HTMLFormElement).submit() - return false + await confirmPassword() + ;(event.target as HTMLFormElement).submit() + return + } + } finally { + isSubmitting.value = false } } @@ -90,7 +104,10 @@ async function onSubmit(event: SubmitEvent) { name="providedRedirectUri" :value="providedRedirectUri"> - + + {{ t('core', 'Grant access') }}