password recover
This commit is contained in:
parent
c1fad4a632
commit
35a3eb0f56
|
|
@ -1,16 +1,51 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<VaForm ref="passwordForm" @submit.prevent="submit">
|
||||||
<h1 class="font-semibold text-4xl mb-4">Check the email</h1>
|
<h1 class="font-semibold text-4xl mb-4">Авторизация по коду</h1>
|
||||||
<p class="text-base mb-4 leading-5">
|
<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>
|
</p>
|
||||||
|
<VaInput v-model="email" :rules="[(v) => !!v || 'Email обязательное поле']" class="mb-4" label="Введите ваш email"
|
||||||
<div class="flex justify-center mt-4">
|
type="email" />
|
||||||
<VaButton :to="{ name: 'login' }" class="w-full">Back to login</VaButton>
|
<VaInput v-model="code" :rules="[(v) => !!v || 'Код обязательное поле']" class="mb-4" label="Введите код из письма"
|
||||||
</div>
|
type="text" />
|
||||||
</div>
|
<VaButton class="w-full mb-2" @click="submit">Авторизоваться</VaButton>
|
||||||
|
</VaForm>
|
||||||
</template>
|
</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>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { inject } from 'vue'
|
||||||
|
import axios from "axios";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { useForm } from "vuestic-ui";
|
import { useForm } from "vuestic-ui";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
|
|
@ -32,10 +34,17 @@ import { useRouter } from "vue-router";
|
||||||
const email = ref("");
|
const email = ref("");
|
||||||
const form = useForm("passwordForm");
|
const form = useForm("passwordForm");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const HOST = inject('HOST');
|
||||||
|
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
if (form.validate()) {
|
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>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue