Skip to content

Commit

Permalink
fix(Permissions): expect "context" in checkPermission
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz committed Apr 22, 2024
1 parent 0a2f137 commit 54b8ef8
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions lib/Service/PermissionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,13 +523,13 @@ private function hasPermission(int $existingPermissions, string $permissionName)
}

/**
* @param mixed $element
* @param 'table'|'view' $nodeType
* @param Table|View|Context $element
* @param 'table'|'view'|'context' $nodeType
* @param string $permission
* @param string|null $userId
* @return bool
*/
private function checkPermission($element, string $nodeType, string $permission, ?string $userId = null): bool {
private function checkPermission(Table|View|Context $element, string $nodeType, string $permission, ?string $userId = null): bool {
if($this->basisCheck($element, $nodeType, $userId)) {
return true;
}
Expand All @@ -542,7 +542,9 @@ private function checkPermission($element, string $nodeType, string $permission,
return $this->getSharedPermissionsIfSharedWithMe($element->getId(), $nodeType, $userId)[$permission];
} catch (NotFoundError $e) {
try {
if ($this->hasPermission($this->getPermissionIfAvailableThroughContext($element->getId(), $nodeType, $userId), $permission)) {
if ($nodeType !== 'context'
&& $this->hasPermission($this->getPermissionIfAvailableThroughContext($element->getId(), $nodeType, $userId), $permission)
) {
return true;
}
} catch (NotFoundError $e) {
Expand Down Expand Up @@ -580,13 +582,7 @@ private function checkPermissionById(int $elementId, string $nodeType, string $p
return false;
}

/**
* @param Table|View|Context $element
* @param string $nodeType
* @param string|null $userId
* @return bool
*/
private function basisCheck($element, string $nodeType, ?string &$userId): bool {
private function basisCheck(Table|View|Context $element, string $nodeType, ?string &$userId): bool {
try {
$userId = $this->preCheckUserId($userId);
} catch (InternalError $e) {
Expand Down

0 comments on commit 54b8ef8

Please sign in to comment.