new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Better Auth · Plugins · all subjects

admin/custom-permissions

4 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Create Access Control function

Use createAccessControl from "better-auth/plugins/access" (not from "better-auth/plugins" to keep bundle sizes small). Pass a statement object with resource names as keys and arrays of actions as values, using `as const` for proper TypeScript inference.

Create custom roles with access control

After creating an access controller with createAccessControl, use ac.newRole() to define roles with specific permissions. Each role is an object with resource names as keys and arrays of actions as values.

Override default roles with custom permissions

When creating custom roles for existing roles like admin or user, predefined permissions will be overridden. To preserve them, import defaultStatements and adminAc from "better-auth/plugins/admin/access", merge defaultStatements into the statement object, and merge the default role's permissions set with the custom role definition using spread operator.

Pass custom roles to admin plugin

Pass roles and access controller to admin plugin on server via adminPlugin({ac, roles: {admin, user, myCustomRole}}) and on client via adminClient({ac, roles: {admin, user, myCustomRole}}).

Give your agent this brain