mirror of
https://github.com/getgrav/grav.git
synced 2025-12-05 23:39:58 +01:00
Minor bug fixes/improvements on $user->authorize()
This commit is contained in:
@@ -1058,7 +1058,7 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
$auth = $user->authorize($act);
|
||||
$auth = $user->authorize($act) ?? false;
|
||||
if (is_bool($auth) && $auth === Utils::isPositive($authenticated)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ class User extends Data implements UserInterface
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use authorize() method instead', E_USER_DEPRECATED);
|
||||
|
||||
return $this->authorize($action);
|
||||
return $this->authorize($action) ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -95,7 +95,7 @@ class UserCollection implements UserCollectionInterface
|
||||
if (Utils::endsWith($file, YAML_EXT)) {
|
||||
$find_user = $this->load(trim(pathinfo($file, PATHINFO_FILENAME)));
|
||||
foreach ($fields as $field) {
|
||||
if ($find_user[$field] === $query) {
|
||||
if (isset($find_user[$field]) && $find_user[$field] === $query) {
|
||||
return $find_user;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ class User extends FlexObject implements UserInterface, MediaManipulationInterfa
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use ->authorize() method instead', E_USER_DEPRECATED);
|
||||
|
||||
return $this->authorize($action);
|
||||
return $this->authorize($action) ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,7 +35,12 @@ trait FlexAuthorizeTrait
|
||||
|
||||
protected function isAuthorizedSuperAdmin(UserInterface $user): bool
|
||||
{
|
||||
return $user->authorize('admin.super');
|
||||
// Action authorization includes super user authorization if using Flex Users.
|
||||
if ($user instanceof FlexObjectInterface) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $user->authorize('admin.super') ?? false;
|
||||
}
|
||||
|
||||
protected function isAuthorizedAction(UserInterface $user, string $action, string $scope = null): bool
|
||||
|
||||
Reference in New Issue
Block a user