Uprava setovani 404 (asi porad nefunguje), ruzne podminky, priprava na zapomenute heslo, sjednoceni nacitani letu v profilu
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
<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 {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");
|
||||
useMeta(() => metaData({
|
||||
title: "Zapomenuté heslo",
|
||||
}));
|
||||
|
||||
const registerUser = () => {
|
||||
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"});
|
||||
})
|
||||
|
||||
}).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."));
|
||||
} else {
|
||||
$q.notify(errorObject("Registrace se nepovedla, zkus to prosím znovu za chvíli"));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const form = ref(null);
|
||||
const formData = reactive({
|
||||
name: "",
|
||||
email: "",
|
||||
password: ""
|
||||
});
|
||||
|
||||
|
||||
const rules = {
|
||||
email: [isRequired, isValidEmail],
|
||||
password: [isRequired, minLength(4)]
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<q-layout view="lHh Lpr lFf">
|
||||
<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="registerUser"
|
||||
>
|
||||
|
||||
<q-input square clearable 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="registerUser"
|
||||
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-page>
|
||||
</q-page-container>
|
||||
</q-layout>
|
||||
</template>
|
||||
Reference in New Issue
Block a user