BA
Better Auth•6mo ago
iRoachie

How to get type for permissions

I'm using the organisation plugin and i have created some custom roles. On the client I have a sidebar where some items are gated depending on the role of the member. So i don't have to go back to the server multiple times, im calling getActiveMember in my layout and passing the role of the active member into the sidebar and then making use of authClient.organization.checkRolePermission. I'd like to specify in a central location all my sidebar items and groups and what permissions are needed to access the page. Is there a way I can get the permission type signature from the checkRolePermission method?
2 Replies
iRoachie
iRoachieOP•6mo ago
Currently doing this Parameters<typeof authClient.organization.checkRolePermission>[0]['permission'] Would be great to have this like authClient.$Infer.Permission
savas
savas•3mo ago
i went the other way (on api.userHasPermission()) and typed it as
permissions: Partial<{
[K in keyof typeof ac.statements]: (typeof ac.statements)[K][number][];
}>
permissions: Partial<{
[K in keyof typeof ac.statements]: (typeof ac.statements)[K][number][];
}>
not sure which is worse 😅

Did you find this page helpful?