mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 08:28:20 +01:00
feat: ✨ Finish password resets code
This commit is contained in:
parent
6566f8c17a
commit
11ece6a8bf
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div class="flex items-center justify-between">
|
||||
<label for="password" class="block text-sm font-medium leading-6 text-gray-50">{{ label }}</label>
|
||||
<label class="block text-sm font-medium leading-6 text-gray-50">{{ label }}</label>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<input v-bind="$attrs" :class="['block disabled:opacity-70 disabled:hover:cursor-wait w-full bg-dark-500 rounded-md border-0 py-1.5 text-gray-50 shadow-sm ring-1 ring-inset ring-white/10 placeholder:text-gray-500 focus:ring-2 focus:ring-inset focus:ring-pink-600 sm:text-sm sm:leading-6',
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<h2 class="font-bold text-lg">An error occured</h2>
|
||||
<span class="text-sm">{{ error_description }}</span>
|
||||
</div>
|
||||
<VeeForm class="space-y-6" method="POST" :validation-schema="schema" :action="`/api/auth/reset`">
|
||||
<VeeForm class="space-y-6" method="POST" :validation-schema="schema" action="/api/auth/reset">
|
||||
<input type="hidden" name="token" :value="token" />
|
||||
|
||||
<h1 class="font-bold text-2xl text-gray-50 text-center tracking-tight">Reset your password</h1>
|
||||
|
|
@ -37,6 +37,14 @@
|
|||
<ButtonsPrimary type="submit" class="w-full">Reset</ButtonsPrimary>
|
||||
</VeeForm>
|
||||
</div>
|
||||
<div v-else-if="success">
|
||||
<h1 class="text-2xl font-bold tracking-tight text-gray-50 sm:text-4xl text-center">Password reset
|
||||
successful!
|
||||
</h1>
|
||||
<p class="mt-6 text-lg leading-8 text-gray-300 text-center">
|
||||
You can now login to your account with your new password.
|
||||
</p>
|
||||
</div>
|
||||
<div v-else class="mx-auto max-w-md">
|
||||
<h1 class="text-2xl font-bold tracking-tight text-gray-50 sm:text-4xl">Invalid access
|
||||
parameters
|
||||
|
|
@ -59,11 +67,14 @@ import { toTypedSchema } from "@vee-validate/zod";
|
|||
import { z } from "zod";
|
||||
import LoginInput from "../../components/LoginInput.vue";
|
||||
|
||||
const tokenData = useTokenData();
|
||||
tokenData.value = null;
|
||||
|
||||
const schema = toTypedSchema(
|
||||
z.object({
|
||||
password: z.string().min(3),
|
||||
password2: z.string().min(3),
|
||||
token: z.string().min(1),
|
||||
z
|
||||
.object({
|
||||
password: z.string().min(3).max(100),
|
||||
password2: z.string().min(3).max(100),
|
||||
})
|
||||
.superRefine((data, ctx) => {
|
||||
if (data.password !== data.password2) {
|
||||
|
|
@ -81,10 +92,16 @@ const query = new URLSearchParams(
|
|||
window?.location.search ?? useRequestURL().search,
|
||||
);
|
||||
const token = query.get("token");
|
||||
const error = query.get("error");
|
||||
const error_description = query.get("error_description");
|
||||
const login_reset = query.get("login_reset") === "true";
|
||||
const success = query.get("success") === "true";
|
||||
let error = query.get("error");
|
||||
let error_description = query.get("error_description");
|
||||
|
||||
if (login_reset) {
|
||||
error = "Login reset";
|
||||
error_description =
|
||||
"Your password has been reset by an administrator. Please change it here.";
|
||||
}
|
||||
|
||||
const validUrlParameters = token;
|
||||
|
||||
const ssoConfig = useSSOConfig();
|
||||
</script>
|
||||
Loading…
Reference in a new issue