23b251be7c70a0fcddea5ab2f47af3f2146fabbf
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>
Languages
TypeScript
98.4%
CSS
1.3%
Shell
0.2%
Dockerfile
0.1%