Skip to content

Commit 0e00dfa

Browse files
committed
WIP adjustments for #5132
see 916e510
1 parent 74dd00b commit 0e00dfa

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

Neos.Neos/Classes/Domain/Model/WorkspacePermissions.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,9 @@ public static function all(): self
4747
{
4848
return new self(true, true, true);
4949
}
50+
51+
public static function none(): self
52+
{
53+
return new self(false, false, false);
54+
}
5055
}

Neos.Neos/Classes/Domain/Service/WorkspaceService.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,19 +302,30 @@ public function getWorkspacePermissionsForUser(ContentRepositoryId $contentRepos
302302
} catch (NoSuchRoleException $e) {
303303
throw new \RuntimeException(sprintf('Failed to determine roles for user "%s", check your package dependencies: %s', $user->getId()->value, $e->getMessage()), 1727084881, $e);
304304
}
305+
306+
$userIsAdministrator = in_array('Neos.Neos:Administrator', $userRoles, true);
307+
308+
if ($userIsAdministrator) {
309+
return WorkspacePermissions::all();
310+
}
311+
305312
$workspaceMetadata = $this->loadWorkspaceMetadata($contentRepositoryId, $workspaceName);
306-
if ($workspaceMetadata !== null && $workspaceMetadata->ownerUserId !== null && $workspaceMetadata->ownerUserId->equals($user->getId())) {
313+
$userIsOwner = $workspaceMetadata !== null && $workspaceMetadata->ownerUserId !== null && $workspaceMetadata->ownerUserId->equals($user->getId());
314+
315+
if ($userIsOwner) {
307316
return WorkspacePermissions::all();
308317
}
318+
309319
$userWorkspaceRole = $this->loadWorkspaceRoleOfUser($contentRepositoryId, $workspaceName, $user->getId(), $userRoles);
310-
$userIsAdministrator = in_array('Neos.Neos:Administrator', $userRoles, true);
320+
311321
if ($userWorkspaceRole === null) {
312-
return WorkspacePermissions::create(false, false, $userIsAdministrator);
322+
return WorkspacePermissions::none();
313323
}
324+
314325
return WorkspacePermissions::create(
315326
read: $userWorkspaceRole->isAtLeast(WorkspaceRole::COLLABORATOR),
316327
write: $userWorkspaceRole->isAtLeast(WorkspaceRole::COLLABORATOR),
317-
manage: $userIsAdministrator || $userWorkspaceRole->isAtLeast(WorkspaceRole::MANAGER),
328+
manage: $userWorkspaceRole->isAtLeast(WorkspaceRole::MANAGER),
318329
);
319330
}
320331

0 commit comments

Comments
 (0)