seyyed
(Arash)
July 27, 2014, 9:13am
1
According to document Yii implements a General Hierarchical RBAC, following the NIST RBAC model.
NIST General Hierarchical model built on top of Flat RBAC + supporting role hierarchy.
So RBAC must support many-to-many user-role assignment.
How can I assign multiple role to a user? it’s seems impossible with Yii::$app->authManager->assign()
Thanks
samdark
(Alexander Makarov)
July 27, 2014, 6:29pm
2
Call: ->assign(‘role1’, $userID); ->assign(‘role2’, $userID); etc.
seyyed
(Arash)
July 27, 2014, 9:42pm
3
first parameter of assign() must be instance of Role I think :
public function assign($role, $userId)
{
if (!isset($this->items[$role->name])) {
throw new InvalidParamException("Unknown role '{$role->name}'.");
...
in below example the user role is the last one.
$role1 = $auth->getRole('role1');
$role2 = $auth->getRole('role2');
$auth->assign($role1, 26);
$auth->assign($role2, 26);
result in assignments.php file is
<?php
return [
26 => 'role2',
];
samdark
(Alexander Makarov)
July 28, 2014, 9:48am
4
Hmm, that’s probably a bug. Can you add it to github? https://github.com/yiisoft/yii2/issues/new Thanks!