From 67ebfe4493382b84a65faa36ae0cc91fb4322790 Mon Sep 17 00:00:00 2001 From: bscheshirwork Date: Fri, 19 Oct 2018 11:56:54 +0300 Subject: [PATCH] Add note about access to switch-identity action --- .../helpful-guides/how-to-swith-identities.md | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/helpful-guides/how-to-swith-identities.md b/docs/helpful-guides/how-to-swith-identities.md index 76e7058..378c0c5 100644 --- a/docs/helpful-guides/how-to-swith-identities.md +++ b/docs/helpful-guides/how-to-swith-identities.md @@ -21,6 +21,39 @@ if(Yii::$app->session->has($module->switchIdentitySessionKey)) { echo Html::a('Switch to Admin', ['/user/admin/switch-identity'], ['data-method' => 'post']); } ``` +> Note: If you use RBAC we can add access for all user to to this action for back to original user available. +```php +... + 'modules' => [ + 'user' => [ + 'controllerMap' => [ + 'admin' => [ + 'class' => Da\User\Controller\AdminController::class, + 'as access' => [ + 'class' => yii\filters\AccessControl::class, + 'rules' => [ + ['allow' => true, 'actions' => ['switch-identity']], + ['allow' => true, 'permissions' => ['administrateUser']], + ], + ], + ], + ], + ], + ], +... +``` +> Also you can define access role `'administratorPermissionName' => 'admin',` where `admin` is have `administrateUser` permission +```php +... + 'modules' => [ + 'user' => [ + 'class' => Da\User\Module::class, + 'administratorPermissionName' => 'admin', + ], + ], +... +``` + Check the [switchIdentitySessionKey](../installation/configuration-options.md#switchidentitysessionkey) documentation for further information regarding this configuration option.