|
4 | 4 | --> |
5 | 5 |
|
6 | 6 | <script setup lang="ts"> |
| 7 | +import { ref } from 'vue' |
7 | 8 | import { getRequestToken } from '@nextcloud/auth' |
8 | 9 | import { loadState } from '@nextcloud/initial-state' |
9 | 10 | import { t } from '@nextcloud/l10n' |
10 | 11 | import { confirmPassword, isPasswordConfirmationRequired, PwdConfirmationMode } from '@nextcloud/password-confirmation' |
11 | 12 | import NcButton from '@nextcloud/vue/components/NcButton' |
| 13 | +import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon' |
12 | 14 | import NcNoteCard from '@nextcloud/vue/components/NcNoteCard' |
13 | 15 | import LoginFlowContainer from '../components/LoginFlow/LoginFlowContainer.vue' |
14 | 16 |
|
@@ -40,19 +42,31 @@ const { |
40 | 42 |
|
41 | 43 | const requestToken = getRequestToken() |
42 | 44 |
|
| 45 | +const isSubmitting = ref(false) |
| 46 | +
|
43 | 47 | /** |
44 | 48 | * Handle submit event to confirm password if required |
45 | 49 | * |
46 | 50 | * @param event - The submit event |
47 | 51 | */ |
48 | 52 | async function onSubmit(event: SubmitEvent) { |
49 | | - if (isPasswordConfirmationRequired(PwdConfirmationMode.Lax)) { |
| 53 | + if (isSubmitting.value) { |
50 | 54 | event.preventDefault() |
51 | | - event.stopPropagation() |
| 55 | + return |
| 56 | + } |
| 57 | +
|
| 58 | + isSubmitting.value = true |
| 59 | + try { |
| 60 | + if (isPasswordConfirmationRequired(PwdConfirmationMode.Lax)) { |
| 61 | + event.preventDefault() |
| 62 | + event.stopPropagation() |
52 | 63 |
|
53 | | - await confirmPassword() |
54 | | - ;(event.target as HTMLFormElement).submit() |
55 | | - return false |
| 64 | + await confirmPassword() |
| 65 | + ;(event.target as HTMLFormElement).submit() |
| 66 | + return |
| 67 | + } |
| 68 | + } finally { |
| 69 | + isSubmitting.value = false |
56 | 70 | } |
57 | 71 | } |
58 | 72 | </script> |
@@ -90,7 +104,14 @@ async function onSubmit(event: SubmitEvent) { |
90 | 104 | name="providedRedirectUri" |
91 | 105 | :value="providedRedirectUri"> |
92 | 106 |
|
93 | | - <NcButton :class="$style.loginFlowGrant__button" type="submit" variant="primary"> |
| 107 | + <NcButton |
| 108 | + :class="$style.loginFlowGrant__button" |
| 109 | + :disabled="isSubmitting" |
| 110 | + type="submit" |
| 111 | + variant="primary"> |
| 112 | + <template v-if="isSubmitting" #icon> |
| 113 | + <NcLoadingIcon /> |
| 114 | + </template> |
94 | 115 | {{ t('core', 'Grant access') }} |
95 | 116 | </NcButton> |
96 | 117 | </form> |
|
0 commit comments