Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make authManger() in UserPanel configurable. #459

Merged
merged 7 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Yii Framework 2 debug extension Change Log
2.1.19 under development
------------------------

- no changes in this release.
- Enh #459: Add `yii\debug\Module::$authManager` for config RBAC manager used by UserPanel to load current user roles and permissions, default is `authManager`. (jafaripur)
samdark marked this conversation as resolved.
Show resolved Hide resolved


2.1.18 August 09, 2021
Expand Down
8 changes: 8 additions & 0 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ class Module extends \yii\base\Module implements BootstrapInterface
* @var LogTarget
*/
public $logTarget;

/**
* @var \yii\rbac\BaseManager|string|array the RBAC access checker [[BaseManager]] object or the application
* component ID of the AuthManager [[BaseManager]].
* @since 2.1.19
*/
public $authManager = 'authManager';

/**
* @var array|Panel[] list of debug panels. The array keys are the panel IDs, and values are the corresponding
* panel class names or configuration arrays. This will be merged with [[corePanels()]].
Expand Down
4 changes: 3 additions & 1 deletion src/panels/UserPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use yii\helpers\VarDumper;
use yii\web\IdentityInterface;
use yii\web\User;
use yii\di\Instance;

/**
* Debugger panel that collects and displays user data.
Expand Down Expand Up @@ -235,7 +236,8 @@ public function save()
$permissionsProvider = null;

try {
$authManager = Yii::$app->getAuthManager();

$authManager = Instance::ensure($this->module->authManager, \yii\rbac\BaseManager::class);
Copy link
Member

@bizley bizley Aug 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not add hard requirement for this, we don't have it currently. This logic must be improved, not sure if we should allow building component here, maybe just to take already built one from the main app? (Something to discuss).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks OK to me. It is similar to what we use in alike cases.


if ($authManager instanceof \yii\rbac\ManagerInterface) {
$roles = ArrayHelper::toArray($authManager->getRolesByUser($this->getUser()->id));
Expand Down