Allow Boolean operators for Permissions
vethan opened this issue · 0 comments
Currently, permissions are provided as a list of BasePermission
instances, treated implicitly as ANDs. It would be grand to instead be able to use AND and OR operators when passing in permissions.
Feature Request Type
- Core functionality
- [ X] Alteration (enhancement/optimization) of existing feature(s)
- New behavior
Description
This has been discussed on discord. Proposed approach is overriding the &
and |
operators for BasePermission
, which would allow permissions to be passed in as follows:
IsAuthed() & (ControlsAccount() | IsAdmin())
This may need some changes to the on_unauthorized
and has_permission
interface, as the separation / statelessness between has_permission
and on_unauthorized
means that a parent permission's on_unauthorized
wouldn't know WHICH of its child permissions failed.
Additionally, some thought will be needed to handling the combination of sync and async combined permissions
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.