diff --git a/resources/js/components/pages/VerifyPasswordModal.vue b/resources/js/components/pages/VerifyPasswordModal.vue index d4c224c..8e40940 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
@@ -42,74 +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 { VueRecaptcha } from 'vue-recaptcha'; -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 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 email = appStore.user?.email; - const res = await AuthApi.login(email, password.value, recaptcha); - if (res.data.Login) { - emit('confirm', password.value); - closeModal(); - } else { - snackbar.error({ - title: 'Error', - text: 'Invalid password', - }); - } -}; - -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 confirm = async () => { + emit('confirm', password.value); + closeModal(); }; const closeModal = () => { emit('closed'); }; -(() => { - loadCaptchaScript(); -})(); +onUnmounted(() => { + password.value = ''; +}); 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); }