diff --git a/apps/provisioning_api/lib/AppInfo/Application.php b/apps/provisioning_api/lib/AppInfo/Application.php index 6d99c48be5..c706cd38a1 100644 --- a/apps/provisioning_api/lib/AppInfo/Application.php +++ b/apps/provisioning_api/lib/AppInfo/Application.php @@ -29,11 +29,14 @@ namespace OCA\Provisioning_API\AppInfo; use OC\AppFramework\Utility\SimpleContainer; use OC\AppFramework\Utility\TimeFactory; +use OC\Group\Manager as GroupManager; use OCA\Provisioning_API\Middleware\ProvisioningApiMiddleware; use OCA\Settings\Mailer\NewUserMailHelper; use OCP\AppFramework\App; use OCP\AppFramework\Utility\IControllerMethodReflector; use OCP\Defaults; +use OCP\IGroupManager; +use OCP\IUser; use OCP\Util; class Application extends App { @@ -58,8 +61,16 @@ class Application extends App { }); $container->registerService('ProvisioningApiMiddleware', function (SimpleContainer $c) use ($server) { $user = $server->getUserManager()->get($c['UserId']); - $isAdmin = $user !== null ? $server->getGroupManager()->isAdmin($user->getUID()) : false; - $isSubAdmin = $user !== null ? $server->getGroupManager()->getSubAdmin()->isSubAdmin($user) : false; + $isAdmin = false; + $isSubAdmin = false; + + if ($user instanceof IUser) { + $groupManager = $server->get(IGroupManager::class); + assert($groupManager instanceof GroupManager); + $isAdmin = $groupManager->isAdmin($user->getUID()); + $isSubAdmin = $groupManager->getSubAdmin()->isSubAdmin($user); + } + return new ProvisioningApiMiddleware( $c->query(IControllerMethodReflector::class), $isAdmin, diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index 88a763f302..e962e6b0e7 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -2115,11 +2115,6 @@ - - - getSubAdmin - - $quota