From 58d3a0b80f723615012d62a77076ae8eecfdcfa9 Mon Sep 17 00:00:00 2001 From: Claude Fable 5 Date: Sun, 5 Jul 2026 05:47:40 +0200 Subject: [PATCH] Define the reset-password form schema in shared Composing z.object() in the web app around a schema imported from @dorfteich/shared mixes two zod type instances and breaks the zodResolver overload on fresh installs (CI). Like the other forms, the schema now lives in the shared package. Part of #20 Co-Authored-By: Claude Fable 5 --- apps/web/src/pages/auth/ResetPasswordPage.tsx | 7 ++----- packages/shared/src/auth.ts | 2 ++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/web/src/pages/auth/ResetPasswordPage.tsx b/apps/web/src/pages/auth/ResetPasswordPage.tsx index 4728fe8..8355955 100644 --- a/apps/web/src/pages/auth/ResetPasswordPage.tsx +++ b/apps/web/src/pages/auth/ResetPasswordPage.tsx @@ -1,23 +1,20 @@ import { zodResolver } from '@hookform/resolvers/zod'; -import { passwordSchema } from '@dorfteich/shared'; +import { resetPasswordFormSchema } from '@dorfteich/shared'; import { useState } from 'react'; import { useForm } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; import { Link, useSearchParams } from 'react-router-dom'; -import { z } from 'zod'; import { Field, FormError } from '../../components/forms'; import { apiPost } from '../../lib/api'; -const formSchema = z.object({ password: passwordSchema }); - export function ResetPasswordPage(): React.JSX.Element { const { t } = useTranslation(); const [params] = useSearchParams(); const [error, setError] = useState(null); const [done, setDone] = useState(false); - const form = useForm({ resolver: zodResolver(formSchema) }); + const form = useForm({ resolver: zodResolver(resetPasswordFormSchema) }); const token = params.get('token') ?? ''; const onSubmit = form.handleSubmit(async (input) => { diff --git a/packages/shared/src/auth.ts b/packages/shared/src/auth.ts index 2f5cb6f..333fb78 100644 --- a/packages/shared/src/auth.ts +++ b/packages/shared/src/auth.ts @@ -66,6 +66,8 @@ export const resetPasswordInputSchema = z.object({ token: z.string().min(16).max(256), password: passwordSchema, }); +/** Form-side schema for the reset page (token travels via URL, not form). */ +export const resetPasswordFormSchema = z.object({ password: passwordSchema }); export const updateProfileInputSchema = z.object({ displayName: z.string().trim().min(1, 'validation.displayName.required').max(80).optional(), locale: z.enum(['de', 'en']).optional(),