Skip to content

Commit 1e986f1

Browse files
committed
fix: include default roles when adding custom viewer role to org plugin
Better Auth's hasPermission uses `options.roles || defaultRoles`, so passing only `{ viewer }` made the built-in owner/admin/member roles unresolvable, causing "not allowed to invite" errors for owners.
1 parent cfa4eb6 commit 1e986f1

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/auth/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { betterAuth } from 'better-auth';
22
import { drizzleAdapter } from 'better-auth/adapters/drizzle';
33
import { emailOTP, organization, role, deviceAuthorization, bearer, captcha, jwt, testUtils } from 'better-auth/plugins';
4+
import { defaultRoles } from 'better-auth/plugins/organization/access';
45
import { apiKey } from '@better-auth/api-key';
56
import { passkey } from '@better-auth/passkey';
67
import { oauthProvider } from '@better-auth/oauth-provider';
@@ -82,6 +83,7 @@ export const auth = betterAuth({
8283
: []),
8384
organization({
8485
roles: {
86+
...defaultRoles,
8587
viewer: role({
8688
organization: [],
8789
member: [],

0 commit comments

Comments
 (0)