Answer the question
In order to leave comments, you need to log in
User->can with "OR" mode?
Hello others.
How to make user->can(role) check only in OR mode?
those. it is necessary to give access to the functionality to several roles, and in order not to write 5-10 times user->can('role1') || user->can('role2') || ...
, is it possible to somehow do a check on the list (array) ala right away user->can(['role1', 'role2', ...])
?
Answer the question
In order to leave comments, you need to log in
Two options:
1. Move the check into a static function.
2. Write your User class, redefine the can function and slip it as a component.
An option with the correct structure of roles, permissions and rules that will not require multiple checks is not considered?
Isn't that what permission is for?
Create, give it to different roles. Or even a list of users.
If there is some logic by which roles and / or users are selected, then there is not permission for this, but rules:
www.yiiframework.com/doc-2.0/guide-security-author...
If it is not suitable, for religious reasons, proposed (although, as for me, the rbac yii2 scheme covers any whim), then - pick up a pencil and write your bike
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question