Documentation of custom roles and permissions with the admin plugin are inaccurate

I guess that the documentation of better auth for custom roles and permissions is inaccurate. If you configure the admin plugin like that:
export const auth = betterAuth({
...
plugins: [
adminPlugin({
accessControl,
roles: {
admin: admin,
patient: patient,
physician: physician
},
})
],
...
});
export const auth = betterAuth({
...
plugins: [
adminPlugin({
accessControl,
roles: {
admin: admin,
patient: patient,
physician: physician
},
})
],
...
});
Only the default statements user and session are accepted in auth.api.userHasRole. If you want to use own permissions you have to also configure the ac property like that:
export const auth = betterAuth({
...
plugins: [
adminPlugin({
ac: accessControl,
roles: {
admin: admin,
patient: patient,
physician: physician
}
})
],
...
});
export const auth = betterAuth({
...
plugins: [
adminPlugin({
ac: accessControl,
roles: {
admin: admin,
patient: patient,
physician: physician
}
})
],
...
});
Is this worth an issue for the documentation?
1 Reply
Durnomagus
DurnomagusOP3w ago
I guess that is true, if the access control constant is not named ac but has another name.

Did you find this page helpful?