Skip to content

Commit 4595994

Browse files
author
Carlos Garcia
committed
Añadida validación para usuarios nulos en el controlador de permisos
1 parent 6686535 commit 4595994

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Core/Lib/ControllerPermissions.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ public function __construct(?User $user = null, ?string $pageName = null)
6161
return;
6262
}
6363

64+
if ($user === null) {
65+
return;
66+
}
67+
6468
if ($user->admin) {
6569
$this->grantAdminPermissions();
6670
} else {
@@ -71,11 +75,11 @@ public function __construct(?User $user = null, ?string $pageName = null)
7175
/**
7276
* Manually set permissions for this controller.
7377
*
74-
* @param bool $access Whether to allow access
75-
* @param int $accessMode The access level
76-
* @param bool $delete Whether to allow delete operations
77-
* @param bool $update Whether to allow update operations
78-
* @param bool $onlyOwner Whether to restrict to owner data only
78+
* @param bool $access Whether to allow access
79+
* @param int $accessMode The access level
80+
* @param bool $delete Whether to allow delete operations
81+
* @param bool $update Whether to allow update operations
82+
* @param bool $onlyOwner Whether to restrict to owner data only
7983
*/
8084
public function set(bool $access, int $accessMode, bool $delete, bool $update, bool $onlyOwner = false): void
8185
{
@@ -173,7 +177,7 @@ private function setProperty(string $property, $value): void
173177
protected function getUserAccess(string $nick, string $pageName): array
174178
{
175179
$cacheKey = $this->buildCacheKey($nick, $pageName);
176-
180+
177181
return Cache::remember($cacheKey, function () use ($nick, $pageName) {
178182
return RoleAccess::allFromUser($nick, $pageName);
179183
});

0 commit comments

Comments
 (0)