Skip to content

Commit

Permalink
Do not show routes on Permissions list when advanced config is enabled.
Browse files Browse the repository at this point in the history
Fix AuthItem::getItems() method too.
  • Loading branch information
re3lex committed Oct 19, 2018
1 parent 63944f9 commit f554f7e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions models/AuthItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,20 @@ public function removeChildren($items)
public function getItems()
{
$manager = Configs::authManager();
$advanced = Configs::instance()->advanced;
$available = [];
if ($this->type == Item::TYPE_ROLE) {
foreach (array_keys($manager->getRoles()) as $name) {
$available[$name] = 'role';
}
}
foreach (array_keys($manager->getPermissions()) as $name) {
$available[$name] = $name[0] == '/' ? 'route' : 'permission';
$available[$name] = $name[0] == '/' || $advanced && $name[0] == '@' ? 'route' : 'permission';
}

$assigned = [];
foreach ($manager->getChildren($this->_item->name) as $item) {
$assigned[$item->name] = $item->type == 1 ? 'role' : ($item->name[0] == '/' ? 'route' : 'permission');
$assigned[$item->name] = $item->type == 1 ? 'role' : ($item->name[0] == '/' || $advanced && $item->name[0] == '@' ? 'route' : 'permission');
unset($available[$item->name]);
}
unset($available[$this->name]);
Expand Down

0 comments on commit f554f7e

Please sign in to comment.