User role property in Organization plugin
Hey,
I'm trying to setup the Organization plugin and I want to only let admin/superadmin roles be able to create new orgs using the
allowUserToCreateOrganization
However, the role property doesn't seem to exist on the user type, even though I have added the admin plugin and migrated the changes on DB. But I still get this error:
Property 'role' does not exist on type '{ id: string; name: string; emailVerified: boolean; email: string; createdAt: Date; updatedAt: Date; image?: string | null | undefined; }'.ts(2339)
7 Replies
Also, here is the code.
Sorry it didn't went through the first time


Yeah that's a common issue in Better auth where existing plugins or schemas won't effect the type def of users or sessions in function properties of the auth config. In most cases you can ignore the type inference and assume that it exists, so if you think this is the case you can just do a
if("role" in user)
sort of thing to checkHey guys, nearly the same issue here. I'd like to be able to create a new "admin" (from admin plugin) user when I use authClient.signUp.email(). However, the role will be always set to default user role. Any idea ?
That is for using a finite set of roles and permissions that have been defined during the requirement phase? You don’t have dynamic roles?
I just set a defaultRole (which is the same as the default one I think) and the list of admin roles. In organisation. My autClient has the 2 client plugins set up.
Last screenshot is a Button and when I click on it, my user is created with the role "user" (the default role I've inserted). Any idea ?



Hi @JackTheRipper and @Ping I created this PR to suppress the ts error https://github.com/better-auth/better-auth/pull/3600
Admin | Better Auth
Admin plugin for Better Auth