docs: has permission on organization doesn't require roles (#727)

This commit is contained in:
Bereket Engida
2024-12-02 16:42:24 +03:00
committed by GitHub
parent 5539c0704a
commit fb8fb25be2

View File

@@ -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`.