From d1062a6b80aa798ef8dab7df7fc4b7470aa14023 Mon Sep 17 00:00:00 2001 From: zlayine Date: Tue, 28 May 2024 08:47:20 +0300 Subject: [PATCH 1/3] fix password query --- .../components/pages/VerifyPasswordModal.vue | 56 +------------------ 1 file changed, 3 insertions(+), 53 deletions(-) diff --git a/resources/js/components/pages/VerifyPasswordModal.vue b/resources/js/components/pages/VerifyPasswordModal.vue index d4c224c..083c25d 100644 --- a/resources/js/components/pages/VerifyPasswordModal.vue +++ b/resources/js/components/pages/VerifyPasswordModal.vue @@ -18,21 +18,11 @@ name="password" type="password" /> -
Cancel - Confirm + Confirm
@@ -45,7 +35,6 @@ import FormInput from '../FormInput.vue'; import { ref } from 'vue'; import { useAppStore } from '~/store'; import { AuthApi } from '~/api/auth'; -import { VueRecaptcha } from 'vue-recaptcha'; import snackbar from '~/util/snackbar'; const props = defineProps<{ isOpen: boolean }>(); @@ -55,14 +44,10 @@ const emit = defineEmits(['closed', 'confirm']); const appStore = useAppStore(); const password = ref(); -const isCaptchaBadgeVisible = ref(false); -const captchaRef = ref(); -const hasCaptcha = window.bootstrap?.captcha_key?.length > 0; -const reCaptchaSiteKey = window.bootstrap?.captcha_key || 'null'; -const confirm = async (recaptcha?: string) => { +const confirm = async () => { const email = appStore.user?.email; - const res = await AuthApi.login(email, password.value, recaptcha); + const res = await AuthApi.updateUser(email, password.value); if (res.data.Login) { emit('confirm', password.value); closeModal(); @@ -74,42 +59,7 @@ const confirm = async (recaptcha?: string) => { } }; -const loadCaptchaScript = async () => { - if (!hasCaptcha) { - isCaptchaBadgeVisible.value = true; - - return; - } - if (!document.getElementById('recaptcha-script')) { - const script = document.createElement('script'); - script.type = 'text/javascript'; - script.id = 'recaptcha-script'; - script.async = true; - script.defer = true; - script.src = 'https://www.google.com/recaptcha/api.js?onload=vueRecaptchaApiLoaded&render=explicit&hl=:1'; - document.getElementsByTagName('head')[0].appendChild(script); - } - - isCaptchaBadgeVisible.value = true; -}; - -const onCaptchaExpired = () => { - captchaRef.value.reset(); -}; - -const verifyCaptcha = () => { - if (!hasCaptcha) { - return confirm(); - } - - captchaRef.value.execute(); -}; - const closeModal = () => { emit('closed'); }; - -(() => { - loadCaptchaScript(); -})(); From 72d745e1ac635722a32829086996dcfc208dfe1c Mon Sep 17 00:00:00 2001 From: zlayine Date: Tue, 28 May 2024 09:00:04 +0300 Subject: [PATCH 2/3] fix collection ids --- resources/js/store/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/store/index.ts b/resources/js/store/index.ts index 941c8b5..63d0688 100644 --- a/resources/js/store/index.ts +++ b/resources/js/store/index.ts @@ -187,7 +187,7 @@ export const useAppStore = defineStore('app', { const res = await CollectionApi.getCollectionsIds(totalCount); const collectionsData = res.data.GetCollections; if (collectionsData.pageInfo.hasNextPage) { - await this.fetchCollectionIds(collectionsData.totalCount); + await this.fetchCollectionIds(collectionsData.totalCount > 500 ? 500 : collectionsData.totalCount); } else { this.collections = collectionsData.edges.map((collection: any) => collection.node.collectionId); } From 563998b4ad8bf20970fc6277945c32f5d8dfa1a3 Mon Sep 17 00:00:00 2001 From: zlayine Date: Tue, 28 May 2024 09:26:52 +0300 Subject: [PATCH 3/3] refactor --- .../components/pages/VerifyPasswordModal.vue | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/resources/js/components/pages/VerifyPasswordModal.vue b/resources/js/components/pages/VerifyPasswordModal.vue index 083c25d..8e40940 100644 --- a/resources/js/components/pages/VerifyPasswordModal.vue +++ b/resources/js/components/pages/VerifyPasswordModal.vue @@ -32,34 +32,24 @@ import { DialogTitle } from '@headlessui/vue'; import Btn from '~/components/Btn.vue'; import Modal from '~/components/Modal.vue'; import FormInput from '../FormInput.vue'; -import { ref } from 'vue'; -import { useAppStore } from '~/store'; -import { AuthApi } from '~/api/auth'; -import snackbar from '~/util/snackbar'; +import { onUnmounted, ref } from 'vue'; const props = defineProps<{ isOpen: boolean }>(); const emit = defineEmits(['closed', 'confirm']); -const appStore = useAppStore(); - const password = ref(); const confirm = async () => { - const email = appStore.user?.email; - const res = await AuthApi.updateUser(email, password.value); - if (res.data.Login) { - emit('confirm', password.value); - closeModal(); - } else { - snackbar.error({ - title: 'Error', - text: 'Invalid password', - }); - } + emit('confirm', password.value); + closeModal(); }; const closeModal = () => { emit('closed'); }; + +onUnmounted(() => { + password.value = ''; +});