Skip to content

Commit 11ece6a

Browse files
committed
feat: ✨ Finish password resets code
1 parent 6566f8c commit 11ece6a

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

components/LoginInput.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="flex items-center justify-between">
3-
<label for="password" class="block text-sm font-medium leading-6 text-gray-50">{{ label }}</label>
3+
<label class="block text-sm font-medium leading-6 text-gray-50">{{ label }}</label>
44
</div>
55
<div class="mt-2">
66
<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',

pages/oauth/reset.vue

+27-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<h2 class="font-bold text-lg">An error occured</h2>
1010
<span class="text-sm">{{ error_description }}</span>
1111
</div>
12-
<VeeForm class="space-y-6" method="POST" :validation-schema="schema" :action="`/api/auth/reset`">
12+
<VeeForm class="space-y-6" method="POST" :validation-schema="schema" action="/api/auth/reset">
1313
<input type="hidden" name="token" :value="token" />
1414

1515
<h1 class="font-bold text-2xl text-gray-50 text-center tracking-tight">Reset your password</h1>
@@ -37,6 +37,14 @@
3737
<ButtonsPrimary type="submit" class="w-full">Reset</ButtonsPrimary>
3838
</VeeForm>
3939
</div>
40+
<div v-else-if="success">
41+
<h1 class="text-2xl font-bold tracking-tight text-gray-50 sm:text-4xl text-center">Password reset
42+
successful!
43+
</h1>
44+
<p class="mt-6 text-lg leading-8 text-gray-300 text-center">
45+
You can now login to your account with your new password.
46+
</p>
47+
</div>
4048
<div v-else class="mx-auto max-w-md">
4149
<h1 class="text-2xl font-bold tracking-tight text-gray-50 sm:text-4xl">Invalid access
4250
parameters
@@ -59,12 +67,15 @@ import { toTypedSchema } from "@vee-validate/zod";
5967
import { z } from "zod";
6068
import LoginInput from "../../components/LoginInput.vue";
6169
70+
const tokenData = useTokenData();
71+
tokenData.value = null;
72+
6273
const schema = toTypedSchema(
63-
z.object({
64-
password: z.string().min(3),
65-
password2: z.string().min(3),
66-
token: z.string().min(1),
67-
})
74+
z
75+
.object({
76+
password: z.string().min(3).max(100),
77+
password2: z.string().min(3).max(100),
78+
})
6879
.superRefine((data, ctx) => {
6980
if (data.password !== data.password2) {
7081
ctx.addIssue({
@@ -81,10 +92,16 @@ const query = new URLSearchParams(
8192
window?.location.search ?? useRequestURL().search,
8293
);
8394
const token = query.get("token");
84-
const error = query.get("error");
85-
const error_description = query.get("error_description");
95+
const login_reset = query.get("login_reset") === "true";
96+
const success = query.get("success") === "true";
97+
let error = query.get("error");
98+
let error_description = query.get("error_description");
8699
87-
const validUrlParameters = token;
100+
if (login_reset) {
101+
error = "Login reset";
102+
error_description =
103+
"Your password has been reset by an administrator. Please change it here.";
104+
}
88105
89-
const ssoConfig = useSSOConfig();
106+
const validUrlParameters = token;
90107
</script>

0 commit comments

Comments
 (0)