Suite 39 — password-reset flow + fix BetterAuthAccount uuid drift - #40
Merged
Conversation
…id drift 39.1 — Wire the Better Auth password-reset flow so passwordless-account rollover (suite 38.A4) is no longer a dead end: - Add emailAndPassword.sendResetPassword in theCommonsWeb/src/lib/auth.ts, sending the reset email directly via the Brevo REST API from the Next server (the frontend has no shared email helper). Fails silently/logged, never throws (anti-enumeration). - Rewire /forgot-password to call authClient.requestPasswordReset instead of a stub. - New public /reset-password?token= page consuming the token via resetPassword. - Requires BREVO_API_KEY (+ optional DIGEST_FROM_EMAIL) in theCommonsWeb PROD env — without it, /forgot-password reports success but no email is sent. 39.2 — Fix latent auth model/schema drift found in 38.A4: - BetterAuthAccount.user_id TextField -> UUIDField (db_column="userId") to match the live neon_auth.account column; ORM anti-joins no longer raise uuid=text. managed=False mirror, so no migration is generated. Added a fast field-type assertion test. Backend 115 tests OK, makemigrations clean; frontend build + 33 tests + lint green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Suite 39 — password-reset flow wiring + auth model drift
Follow-up to Suite 38. Backend 115 tests OK,
makemigrations --checkclean; frontendpnpm build+pnpm test33/33 + lint green.39.1 — Wire Better Auth password-reset (unblocks the 38.A4 rollover)
theCommonsWeb/src/lib/auth.ts— addemailAndPassword.sendResetPassword, sending the reset email directly via the Brevo REST API from the Next server (the frontend had no email helper). Wrapped in try/catch — logs and returns on failure, never throws (matches Better Auth anti-enumeration).ForgotPasswordForm.tsx— replace the stub with a realauthClient.requestPasswordReset({ email, redirectTo: '/reset-password' }).theCommonsWeb/src/app/reset-password/page.tsx+ form — consumes?token=, sets a new password viaauthClient.resetPassword, redirects to sign-in.requestPasswordReset/resetPassword.39.2 — Fix BetterAuthAccount uuid drift
BetterAuthAccount.user_idTextField→UUIDField(db_column="userId") to match the liveneon_auth.accountcolumn.managed=Falsemirror ⇒ no migration generated. Added a fast field-type assertion test. Rollover command keeps its raw SQL (neon_auth mirrors aren't in the test DB); docstring updated.BREVO_API_KEY(and optionallyDIGEST_FROM_EMAIL) to theCommonsWeb's prod server env. Without it,/forgot-passwordreturns success but no reset email is sent (logged, not thrown). The backend already has this key; the frontend did not.Once merged + env set, the 38.A4 rollover (
rollover_passwordless_accounts --send) is unblocked.Note
BetterAuthSession.user_idis stillTextField— 39.2 left it (not confirmed drifted, out of scope). Minor potential follow-up if session ORM joins ever need it.🤖 Generated with Claude Code