-
Notifications
You must be signed in to change notification settings - Fork 1
Subtarget with multiple roles
Adam Pahlevi Baihaqi edited this page Sep 24, 2015
·
3 revisions
In Bali, a subtarget is allowed to have multiple roles.
A subtarget may have multiple roles. For instance, a user may have a role of finance_user
and general_user
.
A general user by itself cannot delete
, or cancel
. A finance_user
, on the other hand, does can. But, if a subtarget has role of both finance_user
and general_user
, he/she can perform delete
or cancel
(so far that the condition is met, if any).
For example, he is given rights of "monitoring" and "finance".
adam = My::Employee.new
adam.roles = [:monitoring, :finance]
To authenticate adam
, perform objector as usual:
txn = My::Transaction.last
txn.can?(adam.roles, :edit)
That is, we can perform authorisation for multiple roles by passing array of roles to it.
When there is conflicting role, role that is defined last will take precedence. Therefore, the ordering of role within the array does matter.