Assigning roles to users problem
mixnblend opened this issue · comments
Hey hey guys.
Just want to say great work on that module. Super easy to set up, and works great so far. I just want to ask what this controller (see attached screenshot) is for?
Is there supposed to be functionality in that controller for assigning users to roles, or is that something that I should implement in my user management controller?
I just wanted to check, because, while I can see how to create permissions, roles, etc very quickly, assigning users to those roles is one thing I can't see how to do using this, and I'm just wondering if I'm missing it here, have set something up incorrectly, or it is something I must implement on top of the module.
best
Jon
Hi, in your grid missing the view link
- assignments grid.
This link opens the following page - assign roles page
On this page you can assign all available roles to user.
In your case for user with ID=66 this link looks as rbac/assignment/view?id=66
Also if you override the gridViewColumns property you should add the view link to your array as follows:
return [
'modules' => [
'admin' => [
'class' => 'app\modules\admin\Module',
'modules' => [
'rbac' => [
'class' => 'yii2mod\rbac\Module',
'controllerMap' => [
'assignment' => [
'class' => 'yii2mod\rbac\controllers\AssignmentController',
'gridViewColumns' => [
'id',
'username',
'email',
// you should add this code
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view}'
]
]
]
]
],
]
],
],
'components' => [
'authManager' => [
'class' => 'yii\rbac\DbManager',
'defaultRoles' => ['guest', 'user']
],
]
];
Hey hey @igor-chepurnoi Thanks for getting back to me so quickly.
Yeah I see,:) Since the action column never changes (i.e. it's just the view link and no others on that grid, would it not be an idea to ArrayHelper::merge the action column with that gridViewColumns array on setup? That way, if it is left out of the gridViewColumns config array, it will be merged in anyway, and if it is defined, then it can be overridden?
Thanks again for putting together such an easy to use module, and thank you again for getting back to me so quickly. Hope this finds you well.
Since the action column never changes (i.e. it's just the view link and no others on that grid, would it not be an idea to ArrayHelper::merge the action column with that gridViewColumns array on setup?
Resolved by 3219ffd
I create the new release 1.8 with this 3219ffd changes. Update your package by composer update
.
Thanks.
Thank you so so much:)
You are welcome :)