password recover
This commit is contained in:
parent
c1fad4a632
commit
35a3eb0f56
|
|
@ -1,16 +1,51 @@
|
|||
<template>
|
||||
<div>
|
||||
<h1 class="font-semibold text-4xl mb-4">Check the email</h1>
|
||||
<VaForm ref="passwordForm" @submit.prevent="submit">
|
||||
<h1 class="font-semibold text-4xl mb-4">Авторизация по коду</h1>
|
||||
<p class="text-base mb-4 leading-5">
|
||||
Password reset instructions have been sent to your email. Check your
|
||||
inbox, including the spam folder if needed. For assistance,
|
||||
<span class="va-link">contact support</span>.
|
||||
Вам был выслан код, введите его и вы авторизуетесь, для смены пароля вам необходимо зайти в настройки профиля.
|
||||
</p>
|
||||
|
||||
<div class="flex justify-center mt-4">
|
||||
<VaButton :to="{ name: 'login' }" class="w-full">Back to login</VaButton>
|
||||
</div>
|
||||
</div>
|
||||
<VaInput v-model="email" :rules="[(v) => !!v || 'Email обязательное поле']" class="mb-4" label="Введите ваш email"
|
||||
type="email" />
|
||||
<VaInput v-model="code" :rules="[(v) => !!v || 'Код обязательное поле']" class="mb-4" label="Введите код из письма"
|
||||
type="text" />
|
||||
<VaButton class="w-full mb-2" @click="submit">Авторизоваться</VaButton>
|
||||
</VaForm>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup></script>
|
||||
<script lang="ts" setup>
|
||||
|
||||
import { inject } from 'vue'
|
||||
import axios from "axios";
|
||||
import { ref } from "vue";
|
||||
import { useForm, useToast } from "vuestic-ui";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
const form = useForm("passwordForm");
|
||||
const code = ref("");
|
||||
const router = useRouter();
|
||||
const HOST = inject('HOST');
|
||||
const email = ref(useRoute().query.email?.toString() || "");
|
||||
const { init } = useToast();
|
||||
|
||||
const submit = () => {
|
||||
if (form.validate()) {
|
||||
axios
|
||||
.post(`${HOST}/api/v0/profiles/passwords/confirm/recover`, {
|
||||
email: email.value,
|
||||
code: code.value,
|
||||
})
|
||||
.then((response) => {
|
||||
localStorage.setItem('token', response.data.token);
|
||||
router.push({ name: "dashboard" }).catch((error) => { });
|
||||
}).catch((error) => {
|
||||
if (error.response.data.detail.code_string == "ObjectNotFound") {
|
||||
init({
|
||||
message: "Неверный код",
|
||||
color: "error",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { inject } from 'vue'
|
||||
import axios from "axios";
|
||||
import { ref } from "vue";
|
||||
import { useForm } from "vuestic-ui";
|
||||
import { useRouter } from "vue-router";
|
||||
|
|
@ -32,10 +34,17 @@ import { useRouter } from "vue-router";
|
|||
const email = ref("");
|
||||
const form = useForm("passwordForm");
|
||||
const router = useRouter();
|
||||
const HOST = inject('HOST');
|
||||
|
||||
const submit = () => {
|
||||
if (form.validate()) {
|
||||
router.push({ name: "recover-password-email" });
|
||||
axios
|
||||
.post(`${HOST}/api/v0/profiles/passwords/require/recover`, {
|
||||
email: email.value,
|
||||
})
|
||||
.then((response) => {
|
||||
router.push({ name: "recover-password-email", query: { email: email.value } });
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue