Bugfixing
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
<script setup>
|
||||
import {reactive, ref} from "vue";
|
||||
import {useRouter} from "vue-router";
|
||||
import {useMeta, useQuasar} from "quasar";
|
||||
import {errorObject, successObject} from "src/composables/dialog";
|
||||
import {useAppStore} from "stores/App";
|
||||
import {isRequired, isValidEmail, minLength} from "src/composables/form/rules";
|
||||
import {isRequired, isValidEmail} from "src/composables/form/rules";
|
||||
import {api} from "boot/axios";
|
||||
import {useAuthStore} from "stores/Auth";
|
||||
import {metaData} from "src/composables/meta";
|
||||
|
||||
const router = useRouter();
|
||||
const $q = useQuasar();
|
||||
|
||||
useAppStore().setPageTitle("Zapomenuté heslo");
|
||||
@@ -18,19 +15,21 @@ useMeta(() => metaData({
|
||||
index: false
|
||||
}));
|
||||
|
||||
const requestPasswordChange = () => {
|
||||
const requestPasswordChange = async () => {
|
||||
if (!form.value.validate()) return;
|
||||
|
||||
return api.post('/forgotten-password/request', formData).then(response => {
|
||||
$q.notify(successObject("Žádost o změnu hesla odeslána, zkontroluj si svůj e-mail."))
|
||||
}).catch(({response}) => {
|
||||
try {
|
||||
await api.post('/forgotten-password/request', formData);
|
||||
$q.notify(successObject("Žádost o změnu hesla odeslána, zkontroluj si svůj e-mail."));
|
||||
} catch (e) {
|
||||
const {response} = e;
|
||||
if (response.status === 404) {
|
||||
$q.notify(errorObject(`E-mail ${formData.email} není registrovaný.`));
|
||||
} else {
|
||||
console.error(response)
|
||||
$q.notify(errorObject("Při odesílání se stala chyba. Zkus to za chvíli znovu."));
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const form = ref(null);
|
||||
@@ -49,39 +48,42 @@ const rules = {
|
||||
<q-page-container>
|
||||
|
||||
<q-page class="row justify-center">
|
||||
<q-card flat square style="width:95%; max-width: 450px; height: 500px">
|
||||
<q-card-section class="bg-primary">
|
||||
<h4 class="text-h5 text-white q-my-md">Zapomenuté heslo</h4>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-form
|
||||
ref="form"
|
||||
class="q-px-sm q-pt-xl q-pb-lg"
|
||||
@submit.prevent="requestPasswordChange"
|
||||
>
|
||||
|
||||
<q-input square clearable v-model="formData.email" type="email" label="E-mail" :rules="rules.email">
|
||||
<q-form
|
||||
ref="form"
|
||||
class="q-px-sm q-pt-xl q-pb-lg"
|
||||
style="width:95%; max-width: 450px; height: 500px"
|
||||
@submit.prevent="requestPasswordChange"
|
||||
>
|
||||
|
||||
<q-card flat square>
|
||||
<q-card-section class="bg-primary">
|
||||
<h4 class="text-h5 text-white q-my-md">Zapomenuté heslo</h4>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-input v-model="formData.email" type="email" label="E-mail" :rules="rules.email">
|
||||
<template v-slot:prepend>
|
||||
<q-icon name="email"/>
|
||||
</template>
|
||||
</q-input>
|
||||
|
||||
</q-form>
|
||||
</q-card-section>
|
||||
<q-card-actions class="q-px-lg">
|
||||
<q-btn
|
||||
@click="requestPasswordChange"
|
||||
unelevated
|
||||
size="lg"
|
||||
color="primary"
|
||||
class="full-width"
|
||||
label="Resetovat heslo"
|
||||
/>
|
||||
</q-card-actions>
|
||||
<q-card-section class="text-center q-pa-sm">
|
||||
<router-link :to="{name: 'login'}" class="text-grey-6">Zpět na login</router-link>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-card-section>
|
||||
<q-card-actions>
|
||||
<q-btn
|
||||
@click="requestPasswordChange"
|
||||
unelevated
|
||||
size="lg"
|
||||
color="primary"
|
||||
class="full-width"
|
||||
label="Resetovat heslo"
|
||||
/>
|
||||
</q-card-actions>
|
||||
<q-card-section class="text-center q-pa-sm">
|
||||
<router-link :to="{name: 'login'}" class="text-grey-6">Zpět na login</router-link>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-form>
|
||||
|
||||
</q-page>
|
||||
</q-page-container>
|
||||
</q-layout>
|
||||
|
||||
Reference in New Issue
Block a user