- Move api.server.ts, errors.ts, types.ts, utils.ts, relativeTime.ts to lib/shared/ - Move person relationship components to lib/person/relationship/ - Move Stammbaum components to lib/person/genealogy/ - Move HelpPopover to lib/shared/primitives/ - Update all import paths across routes, specs, and lib files - Update vi.mock() paths in server-project test files - Remove now-empty legacy directories (components/, hooks/, server/, etc.) - Update vite.config.ts coverage include paths for new structure - Update frontend/CLAUDE.md to reflect domain-based lib/ layout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { fail } from '@sveltejs/kit';
|
|
import type { Actions, PageServerLoad } from './$types';
|
|
import { createApiClient } from '$lib/shared/api.server';
|
|
import { parseBackendError } from '$lib/shared/errors';
|
|
|
|
export const load: PageServerLoad = async ({ url }) => {
|
|
const token = url.searchParams.get('token');
|
|
return { token };
|
|
};
|
|
|
|
export const actions = {
|
|
default: async ({ request, fetch }) => {
|
|
const formData = await request.formData();
|
|
const token = formData.get('token') as string;
|
|
const newPassword = formData.get('newPassword') as string;
|
|
const confirmPassword = formData.get('confirmPassword') as string;
|
|
|
|
if (newPassword !== confirmPassword) {
|
|
return fail(400, { error: 'MISMATCH' });
|
|
}
|
|
|
|
const api = createApiClient(fetch);
|
|
const result = await api.POST('/api/auth/reset-password', {
|
|
body: { token, newPassword }
|
|
});
|
|
|
|
if (!result.response.ok) {
|
|
const backendError = await parseBackendError(result.response);
|
|
return fail(400, { error: backendError?.code ?? 'INTERNAL_ERROR' });
|
|
}
|
|
|
|
return { success: true };
|
|
}
|
|
} satisfies Actions;
|