mirror of
https://github.com/vernu/textbee.git
synced 2026-07-30 17:07:46 -04:00
Login showed no message on wrong credentials and just reloaded. The handler called signIn with redirect:true, which makes next-auth navigate on both success and failure, so the browser reloaded to /login?error= and the `if (result?.error)` branch never ran: the error handling was dead code. Switched to redirect:false, so the result is read here, the message renders, and success navigates via router.push + refresh. The password-reset (OTP) form had two related bugs, both found while verifying the "check forgot-password too" ask: - It set form error under `root.serverError` but the JSX rendered `errors.root.message`, which a nested key leaves undefined, so a failed reset showed an empty paragraph and no text. - The catch swallowed the error, so react-hook-form's isSubmitSuccessful stayed true and the "Password reset successful" alert rendered even on failure. The success alert is now gated on the absence of a root error, and errors are cleared at the start of each submit. register-form was already correct (redirect:false); added a regression test so the login bug cannot reappear there unnoticed. Tests: component specs for all three forms under vitest + RTL, with useTurnstile and the network boundary mocked. Each new failing case was confirmed to fail against the pre-change component before the fix. The login signIn mock reflects real redirect semantics (redirect:true yields no readable result), so the "shows an error" test is a faithful guard. Verified: typecheck clean, build clean, 0 lint errors (20 warnings, unchanged), 164 unit tests (from 155). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>