adds password reset

This commit is contained in:
Christian Beutel
2024-11-17 21:49:46 +01:00
parent 7c1304f159
commit b9ae01846b
30 changed files with 791 additions and 247 deletions

View File

@@ -0,0 +1,20 @@
import { pb } from "$lib/pocketbase";
import { error, json, type RequestEvent } from "@sveltejs/kit";
import { ClientResponseError } from "pocketbase";
export async function POST(event: RequestEvent) {
try {
let data;
try {
data = await event.request.json()
} catch (e) {
throw new ClientResponseError({ status: 400, response: { message: "Invalid json" } })
}
const r = await pb.collection('users').confirmPasswordReset(data.token, data.password, data.passwordConfirm);
return json(r);
} catch (e: any) {
throw error(e.status, e);
}
}

View File

@@ -0,0 +1,20 @@
import { pb } from "$lib/pocketbase";
import { error, json, type RequestEvent } from "@sveltejs/kit";
import { ClientResponseError } from "pocketbase";
export async function POST(event: RequestEvent) {
try {
let data;
try {
data = await event.request.json()
} catch (e) {
throw new ClientResponseError({ status: 400, response: { message: "Invalid json" } })
}
const r = await pb.collection('users').requestPasswordReset(data.email);
return json(r);
} catch (e: any) {
throw error(e.status, e);
}
}