diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index a6f4e9c600aa8f858b24f0d7a090d6c9d01a6db6..e35a5d4cb429be4ae5a2b9f9bee88733173b989d 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -47,6 +47,8 @@ use OCP\User\Events\BeforeUserDeletedEvent; use OCP\User\Events\PasswordUpdatedEvent; use OCP\User\Events\UserChangedEvent; use OCP\Util; +use OCP\IUserSession; +use OCP\IGroupManager; class Application extends App implements IBootstrap { public const APP_ID = 'ecloud-accounts'; @@ -79,8 +81,31 @@ class Application extends App implements IBootstrap { * @internal */ public function addStorageWrapper(): void { - Filesystem::addStorageWrapper('ecloud-accounts', [$this, 'addStorageWrapperCallback'], -10); + $userSession = \OC::$server->get(IUserSession::class); + $currentUser = $userSession->getUser(); + if ($currentUser === null) { + Filesystem::addStorageWrapper('ecloud-accounts', [$this, 'addStorageWrapperCallback'], -10); + return; + } + + $groupManager = \OC::$server->get(IGroupManager::class); + $groups = $groupManager->getUserGroups($currentUser); + $hasAccess = false; + + if (!empty($groups)) { + foreach ($groups as $group) { + if($group->getGID() === "storage_enable") { + $hasAccess = true; + break; + } + } + } + + if(!$hasAccess) { + Filesystem::addStorageWrapper('ecloud-accounts', [$this, 'addStorageWrapperCallback'], -10); + } } + /** * @internal