Added support for hiding parts of admin by Deny permissions (Flex Users only)

This commit is contained in:
Matias Griese
2019-11-13 11:49:18 +02:00
parent f7e8a4f076
commit f67f722252
3 changed files with 11 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
# v1.10.0-rc.2
## mm/dd/2019
1. [](#new)
* Added support for hiding parts of admin by `Deny` permissions (`Flex Users` only)
1. [](#improved)
* Improved `permissions` field to add support for displaying calculated permissions
1. [](#bugfix)

View File

@@ -341,7 +341,7 @@ class AdminPlugin extends Plugin
unset($this->grav['user']);
$this->grav['user'] = $user;
$user->authenticated = true;
$user->authorized = $user->authorize('admin.login');
$user->authorized = $user->authorize('admin.login') ?? false;
$messages = $this->grav['messages'];
$messages->add($this->grav['language']->translate('PLUGIN_ADMIN.LOGIN_LOGGED_IN'), 'info');

View File

@@ -27,6 +27,7 @@ use Grav\Common\User\User;
use Grav\Common\Utils;
use Grav\Framework\Collection\ArrayCollection;
use Grav\Framework\Flex\Flex;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
use Grav\Framework\Route\Route;
use Grav\Framework\Route\RouteFactory;
use Grav\Plugin\Login\Login;
@@ -698,8 +699,14 @@ class Admin
{
$action = (array)$action;
$user = $this->user;
foreach ($action as $a) {
if ($this->user->authorize($a)) {
// Ignore 'admin.super' if it's not the only value to be checked.
if ($a === 'admin.super' && count($action) > 1 && $user instanceof FlexObjectInterface) {
continue;
}
if ($user->authorize($a)) {
return true;
}
}