[GH-ISSUE #691] Q: hasPermission - role #17014

Closed
opened 2026-04-15 14:57:33 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @impactvelocity on GitHub (Nov 29, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/691

Great project!

Quick question for the organizaiton.hasPermission

https://www.better-auth.com/docs/plugins/organization#access-control-usage

const canCreateProject = await client.organization.hasPermission({
role: "admin",
permission: {
project: ["create"]
}
})

It seems to work with or without passing the role. I wonder why you need to pass the role? Wouldn't the role be inherited from the active user? Which it seems to be doing.

So I am just passing the permissions, and that is working.

Just wanted to ask and make sure I am understanding it.

Originally created by @impactvelocity on GitHub (Nov 29, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/691 Great project! Quick question for the organizaiton.hasPermission https://www.better-auth.com/docs/plugins/organization#access-control-usage const canCreateProject = await client.organization.hasPermission({ role: "admin", permission: { project: ["create"] } }) It seems to work with or without passing the role. I wonder why you need to pass the role? Wouldn't the role be inherited from the active user? Which it seems to be doing. So I am just passing the permissions, and that is working. Just wanted to ask and make sure I am understanding it.
GiteaMirror added the locked label 2026-04-15 14:57:33 -05:00
Author
Owner

@salvinoto commented on GitHub (Dec 1, 2024):

As far as I'm aware I believe the example is showing you can do either or. Meaning you can pass in the role you want it to be OR the specific permission.

<!-- gh-comment-id:2510309270 --> @salvinoto commented on GitHub (Dec 1, 2024): As far as I'm aware I believe the example is showing you can do either or. Meaning you can pass in the role you want it to be OR the specific permission.
Author
Owner

@Bekacru commented on GitHub (Dec 2, 2024):

The docs were wrong. it doesn't require roles.

<!-- gh-comment-id:2511581352 --> @Bekacru commented on GitHub (Dec 2, 2024): The docs were wrong. it doesn't require roles.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#17014