[Enhancement] Support OR condition for permission checking
Closed this issue · 2 comments
elton-lau commented
I am currently using rbac service for the below use case:
ADMIN -> USER -> VIEWER
I understand that the current inheritance supports 1 level only. If I define VIEWER permission, then ADMIN might not be able to use it. Therefore, I am currently adding a helper function that:
- allows list of list of permissions input (string[][])
- loop through each of the permission list to check
- given at least 1 permission list returns true, then the user is authorized
const promises = permissions.map(async permission => {
return (await this.rbac.getRole(role)).can(...permission)
})
const authorized = (await Promise.all(promises)).some(result => result)
Would like to know if it makes sense to you all. If then, I may open a PR for this feature.
sergey-telpuk commented
@eltonlau1994 thanks for using RBAC! It'll be great to see PR