Commit Graph
5 Commits
Author SHA1 Message Date
Leon Tonhäuser 86dfe8053d fix: harden production flows and user messaging 2026-08-11 16:07:13 +02:00
Leon TonhäuserandClaude 23b251be7c fix(auth): declare role as additionalField so sessions include it
Better Auth's parseUserOutput filters the session user to declared fields
only (filterOutputFields over getFields(options,'user','output')). The drizzle
adapter selects the custom `role` column, but because it was never declared in
the Better Auth config, parseUserOutput stripped it — session.user.role was
always undefined. That broke two things: the root redirect fell through to
/redaktion/alben for admins (role !== 'ADMIN'), and requireAdmin threw
ADMIN_REQUIRED on every /admin page (role !== 'ADMIN').

Declare role via user.additionalFields (the documented custom-field API; the
`fields` map only renames core columns). input:false keeps it unsettable on
signUp — the DB default and the admin seed own it — and defaultValue matches
the column default so inserts never send null into the NOT NULL portalRole enum.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-11 01:41:18 +02:00
Leon TonhäuserandClaude 33b9076cd3 fix(auth): generate UUID ids to match uuid schema columns
Better Auth's default id generator emits a nanoid-style string, but
every id column in the schema is typed uuid. Better Auth passes its
generated id explicitly on insert (bypassing the column defaultRandom),
so Postgres rejected every signUp/session/verification insert with
'invalid input syntax for type uuid'. This broke live registration and
the admin seed alike. Configure advanced.database.generateId to return
crypto.randomUUID() so ids match the schema.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-10 23:41:47 +02:00
Leon Tonhäuser a8d4e54ffb fix: harden editorial registration flow 2026-08-09 21:04:50 +02:00
Leon Tonhäuser 9b22752ef2 feat: add editorial registration and authentication 2026-08-09 20:48:43 +02:00