Org Dynamic Access Control - updateOrgRole error
Issue: user with Owner role cant updateOrgRole
For an org say Org1, I changed the role of an existing user2 from Member->Owner.
User2 (owner) can create new OrgRole with all the permissions, but cant update, when user2, tries to update an existing OrgRole, 1. the name update is working, 2. but the resource:Actions permisssions is throwing error Here is what i tested, which returned success, so user2 has permissions for all resource:actions. but updating an orgRole, gave error. Note: The same user can "create" a newRole with any resource:[Actions], but cant update certain actions.
User2 (owner) can create new OrgRole with all the permissions, but cant update, when user2, tries to update an existing OrgRole, 1. the name update is working, 2. but the resource:Actions permisssions is throwing error Here is what i tested, which returned success, so user2 has permissions for all resource:actions. but updating an orgRole, gave error. Note: The same user can "create" a newRole with any resource:[Actions], but cant update certain actions.
3 Replies
Addition Data:
Somehow better-auth is assuming the user as admin,
but in db, Members table clearly shows the role as "owner". [img attached]
--------------------
in my permissions file, i have restricted admin for these 'project:delete', 'billing:update' and better-auth restricts 'organization:delete', thats ok if the user is admin, but user2 has "owner" role.

Found the bug:
in updateOrgRole, the member is fetched as,
where clause is missing user check.
whereas in createOrgRole, its correct
i have an user(user3) with role as admin, it seems findOne finds that user.
Changing user3 to role "Owner" doesnt throw error.
so, yeah the get member where clause is the issue. its missing userid check
Solution
seems fixed in v1.3.10-beta.5 - i am on latest stable release - v1.3.9