Reset hesla
This commit is contained in:
@@ -17,35 +17,29 @@ useMeta(() => metaData({
|
||||
title: "Zapomenuté heslo",
|
||||
}));
|
||||
|
||||
const registerUser = () => {
|
||||
const requestPasswordChange = () => {
|
||||
if (!form.value.validate()) return;
|
||||
|
||||
return api.post('/forgotten-password', formData).then(response => {
|
||||
useAuthStore().login({email: formData.email, password: formData.password}).then(() => {
|
||||
$q.notify(successObject("Registrace úspěšná, vítej!"));
|
||||
router.push({name: "myFlights"});
|
||||
})
|
||||
|
||||
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}) => {
|
||||
if (response.detail === 'User already exists') {
|
||||
$q.notify(errorObject("Uživatel s tímto e-mailem je již registrovaný. Zkus se přihlásit."));
|
||||
if (response.status === 404) {
|
||||
$q.notify(errorObject(`E-mail ${formData.email} není registrovaný.`));
|
||||
} else {
|
||||
$q.notify(errorObject("Registrace se nepovedla, zkus to prosím znovu za chvíli"));
|
||||
console.error(response)
|
||||
$q.notify(errorObject("Při odesílání se stala chyba. Zkus to za chvíli znovu."));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const form = ref(null);
|
||||
const formData = reactive({
|
||||
name: "",
|
||||
email: "",
|
||||
password: ""
|
||||
});
|
||||
|
||||
|
||||
const rules = {
|
||||
email: [isRequired, isValidEmail],
|
||||
password: [isRequired, minLength(4)]
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -62,7 +56,7 @@ const rules = {
|
||||
<q-form
|
||||
ref="form"
|
||||
class="q-px-sm q-pt-xl q-pb-lg"
|
||||
@submit.prevent="registerUser"
|
||||
@submit.prevent="requestPasswordChange"
|
||||
>
|
||||
|
||||
<q-input square clearable v-model="formData.email" type="email" label="E-mail" :rules="rules.email">
|
||||
@@ -75,7 +69,7 @@ const rules = {
|
||||
</q-card-section>
|
||||
<q-card-actions class="q-px-lg">
|
||||
<q-btn
|
||||
@click="registerUser"
|
||||
@click="requestPasswordChange"
|
||||
unelevated
|
||||
size="lg"
|
||||
color="primary"
|
||||
|
||||
Reference in New Issue
Block a user