|
@@ -1,17 +1,8 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <q-page
|
|
|
|
|
- class="login-page"
|
|
|
|
|
- padding
|
|
|
|
|
- >
|
|
|
|
|
- <q-card
|
|
|
|
|
- class="login-card q-pa-lg bg-surface"
|
|
|
|
|
- flat
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <q-page class="login-page" padding>
|
|
|
|
|
+ <q-card class="login-card q-pa-lg bg-surface" flat>
|
|
|
<div class="text-center">
|
|
<div class="text-center">
|
|
|
- <q-img
|
|
|
|
|
- src="images/kizzo_logo.svg"
|
|
|
|
|
- style="max-width: 220px"
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <q-img src="images/kizzo_logo.svg" style="max-width: 220px" />
|
|
|
|
|
|
|
|
<div
|
|
<div
|
|
|
class="text-weight-regular"
|
|
class="text-weight-regular"
|
|
@@ -28,9 +19,17 @@
|
|
|
autocorrect="off"
|
|
autocorrect="off"
|
|
|
class="q-pa-md"
|
|
class="q-pa-md"
|
|
|
spellcheck="false"
|
|
spellcheck="false"
|
|
|
- @submit="submitLogin"
|
|
|
|
|
|
|
+ @submit="isForgotPassword ? submitForgotPassword() : submitLogin()"
|
|
|
>
|
|
>
|
|
|
<q-card-section class="q-mt-sm flex column q-gutter-y-md">
|
|
<q-card-section class="q-mt-sm flex column q-gutter-y-md">
|
|
|
|
|
+ <q-banner
|
|
|
|
|
+ v-if="isForgotPassword"
|
|
|
|
|
+ class="bg-primary text-white"
|
|
|
|
|
+ rounded
|
|
|
|
|
+ >
|
|
|
|
|
+ Informe seu email para receber o link de recuperação de senha.
|
|
|
|
|
+ </q-banner>
|
|
|
|
|
+
|
|
|
<q-input
|
|
<q-input
|
|
|
v-model="email"
|
|
v-model="email"
|
|
|
hide-bottom-space
|
|
hide-bottom-space
|
|
@@ -41,21 +40,42 @@
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
<DefaultPasswordInput
|
|
<DefaultPasswordInput
|
|
|
|
|
+ v-if="!isForgotPassword"
|
|
|
v-model="password"
|
|
v-model="password"
|
|
|
hide-bottom-space
|
|
hide-bottom-space
|
|
|
label="senha"
|
|
label="senha"
|
|
|
:rules="[inputRules.required, inputRules.min(6)]"
|
|
:rules="[inputRules.required, inputRules.min(6)]"
|
|
|
/>
|
|
/>
|
|
|
|
|
+
|
|
|
|
|
+ <div v-if="!isForgotPassword" class="text-right">
|
|
|
|
|
+ <span
|
|
|
|
|
+ class="text-primary cursor-pointer"
|
|
|
|
|
+ style="font-size: 14px"
|
|
|
|
|
+ @click="enableForgotPassword"
|
|
|
|
|
+ >
|
|
|
|
|
+ Trocar senha
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div v-if="isForgotPassword" class="text-right">
|
|
|
|
|
+ <span
|
|
|
|
|
+ class="text-primary cursor-pointer"
|
|
|
|
|
+ style="font-size: 14px"
|
|
|
|
|
+ @click="cancelForgotPassword"
|
|
|
|
|
+ >
|
|
|
|
|
+ Voltar para login
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </div>
|
|
|
</q-card-section>
|
|
</q-card-section>
|
|
|
|
|
|
|
|
<q-card-actions align="right" class="q-px-md q-mt-md">
|
|
<q-card-actions align="right" class="q-px-md q-mt-md">
|
|
|
<q-btn
|
|
<q-btn
|
|
|
class="full-width"
|
|
class="full-width"
|
|
|
color="primary"
|
|
color="primary"
|
|
|
- label="Entrar"
|
|
|
|
|
- type="submit"
|
|
|
|
|
size="md"
|
|
size="md"
|
|
|
style="border-radius: 8px"
|
|
style="border-radius: 8px"
|
|
|
|
|
+ type="submit"
|
|
|
|
|
+ :label="isForgotPassword ? 'Enviar link' : 'Entrar'"
|
|
|
:loading="submitting"
|
|
:loading="submitting"
|
|
|
>
|
|
>
|
|
|
<template #loading>
|
|
<template #loading>
|
|
@@ -70,6 +90,7 @@
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
import { onMounted, ref } from "vue";
|
|
import { onMounted, ref } from "vue";
|
|
|
|
|
+import { sendForgotPasswordToken } from "src/api/forgotPassword";
|
|
|
import { useAuth } from "src/composables/useAuth";
|
|
import { useAuth } from "src/composables/useAuth";
|
|
|
import { useInputRules } from "src/composables/useInputRules";
|
|
import { useInputRules } from "src/composables/useInputRules";
|
|
|
import { useQuasar } from "quasar";
|
|
import { useQuasar } from "quasar";
|
|
@@ -84,10 +105,62 @@ const $q = useQuasar();
|
|
|
const { inputRules } = useInputRules();
|
|
const { inputRules } = useInputRules();
|
|
|
|
|
|
|
|
const email = ref("");
|
|
const email = ref("");
|
|
|
|
|
+
|
|
|
const password = ref(process.env.PASSWORD);
|
|
const password = ref(process.env.PASSWORD);
|
|
|
|
|
+
|
|
|
const submitting = ref(false);
|
|
const submitting = ref(false);
|
|
|
|
|
+
|
|
|
const loginForm = ref(null);
|
|
const loginForm = ref(null);
|
|
|
|
|
|
|
|
|
|
+const isForgotPassword = ref(false);
|
|
|
|
|
+
|
|
|
|
|
+const enableForgotPassword = () => {
|
|
|
|
|
+ isForgotPassword.value = true;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const cancelForgotPassword = () => {
|
|
|
|
|
+ isForgotPassword.value = false;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const submitForgotPassword = async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ submitting.value = true;
|
|
|
|
|
+
|
|
|
|
|
+ const validate = await loginForm.value.validate();
|
|
|
|
|
+
|
|
|
|
|
+ if (!validate) {
|
|
|
|
|
+ submitting.value = false;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ await sendForgotPasswordToken({
|
|
|
|
|
+ email: email.value,
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ $q.notify({
|
|
|
|
|
+ type: "positive",
|
|
|
|
|
+ message: "Enviamos um link de recuperação para seu email.",
|
|
|
|
|
+ position: "top-right",
|
|
|
|
|
+ timeout: 5000,
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ isForgotPassword.value = false;
|
|
|
|
|
+
|
|
|
|
|
+ submitting.value = false;
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ submitting.value = false;
|
|
|
|
|
+
|
|
|
|
|
+ $q.notify({
|
|
|
|
|
+ type: "negative",
|
|
|
|
|
+ message:
|
|
|
|
|
+ error?.response?.data?.message ||
|
|
|
|
|
+ "Erro ao enviar email de recuperação.",
|
|
|
|
|
+ position: "top-right",
|
|
|
|
|
+ timeout: 5000,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
const submitLogin = async () => {
|
|
const submitLogin = async () => {
|
|
|
try {
|
|
try {
|
|
|
submitting.value = true;
|
|
submitting.value = true;
|
|
@@ -107,10 +180,12 @@ const submitLogin = async () => {
|
|
|
router.push({ name: "DashboardPage" });
|
|
router.push({ name: "DashboardPage" });
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
submitting.value = false;
|
|
submitting.value = false;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$q.notify({
|
|
$q.notify({
|
|
|
type: "negative",
|
|
type: "negative",
|
|
|
- message: error?.response?.data?.message || "Falha no login. Verifique suas credenciais.",
|
|
|
|
|
|
|
+ message:
|
|
|
|
|
+ error?.response?.data?.message ||
|
|
|
|
|
+ "Falha no login. Verifique suas credenciais.",
|
|
|
position: "top-right",
|
|
position: "top-right",
|
|
|
timeout: 5000,
|
|
timeout: 5000,
|
|
|
});
|
|
});
|