mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-10 12:27:44 +00:00
docs: has permission on organization doesn't require roles (#727)
This commit is contained in:
@@ -647,19 +647,15 @@ the plugin providers easy way to define your own set of permission for each role
|
||||
|
||||
### Access Control Usage
|
||||
|
||||
**Has Permisson**:
|
||||
**Has Permission**:
|
||||
|
||||
You can use the `hasPermission` action provided by the `api` to check the permission of the user.
|
||||
|
||||
```ts title="api.ts"
|
||||
import { auth } from "@/auth";
|
||||
|
||||
auth.api.hasPermission({
|
||||
headers: await headers(),
|
||||
body: {
|
||||
role: {
|
||||
in: ['admin']
|
||||
},
|
||||
permission: {
|
||||
project: ["create"] // This must match the structure in your access control
|
||||
}
|
||||
@@ -671,7 +667,6 @@ If you want to check the permission of the user on the client from the server yo
|
||||
|
||||
```ts title="client.ts"
|
||||
const canCreateProject = await client.organization.hasPermission({
|
||||
role: "admin",
|
||||
permission: {
|
||||
project: ["create"]
|
||||
}
|
||||
@@ -860,7 +855,7 @@ const auth = betterAuth({
|
||||
|
||||
**allowUserToCreateOrganization**: `boolean` | `((user: User) => Promise<boolean> | boolean)` - A function that determines whether a user can create an organization. By default, it's `true`. You can set it to `false` to restrict users from creating organizations.
|
||||
|
||||
**organizationLimit**: `numbe` | `((user: User) => Promise<boolean> | boolean)` - The maximum number of organizations allowed for a user. By default, it's `5`. You can set it to any number you want or a function that returns a boolean.
|
||||
**organizationLimit**: `number` | `((user: User) => Promise<boolean> | boolean)` - The maximum number of organizations allowed for a user. By default, it's `5`. You can set it to any number you want or a function that returns a boolean.
|
||||
|
||||
**creatorRole**: `admin | owner` - The role of the user who creates the organization. By default, it's `owner`. You can set it to `admin`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user