diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-02-29 11:29:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-29 11:29:05 +0100 |
commit | d692b2a94bdaf030a0b647c9e31a53fda827cd5b (patch) | |
tree | c8e81c6721c123c3837fe5a58a462996130154d6 /lib | |
parent | f7470ab973d9dc3c979accd95985d71cf80653fa (diff) | |
parent | a23cf50d5e629d21c8c08494668b6c721684d920 (diff) | |
download | nextcloud-server-d692b2a94bdaf030a0b647c9e31a53fda827cd5b.tar.gz nextcloud-server-d692b2a94bdaf030a0b647c9e31a53fda827cd5b.zip |
Merge pull request #43817 from nextcloud/backport/42706/stable28
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Group/Manager.php | 3 | ||||
-rw-r--r-- | lib/private/legacy/OC_User.php | 22 |
2 files changed, 13 insertions, 12 deletions
diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php index eb9daebb222..dafbe4295a4 100644 --- a/lib/private/Group/Manager.php +++ b/lib/private/Group/Manager.php @@ -52,6 +52,7 @@ use OCP\IGroup; use OCP\IGroupManager; use OCP\IUser; use Psr\Log\LoggerInterface; +use function is_string; /** * Class Manager @@ -356,7 +357,7 @@ class Manager extends PublicEmitter implements IGroupManager { */ public function isAdmin($userId) { foreach ($this->backends as $backend) { - if ($backend->implementsActions(Backend::IS_ADMIN) && $backend->isAdmin($userId)) { + if (is_string($userId) && $backend->implementsActions(Backend::IS_ADMIN) && $backend->isAdmin($userId)) { return true; } } diff --git a/lib/private/legacy/OC_User.php b/lib/private/legacy/OC_User.php index d2dc2a2389f..dc172ba4144 100644 --- a/lib/private/legacy/OC_User.php +++ b/lib/private/legacy/OC_User.php @@ -38,7 +38,10 @@ use OC\User\LoginException; use OCP\EventDispatcher\IEventDispatcher; +use OCP\IGroupManager; +use OCP\IUser; use OCP\IUserManager; +use OCP\Server; use OCP\User\Events\BeforeUserLoggedInEvent; use OCP\User\Events\UserLoggedInEvent; use Psr\Log\LoggerInterface; @@ -93,7 +96,7 @@ class OC_User { case 'database': case 'mysql': case 'sqlite': - \OCP\Server::get(LoggerInterface::class)->debug('Adding user backend ' . $backend . '.', ['app' => 'core']); + Server::get(LoggerInterface::class)->debug('Adding user backend ' . $backend . '.', ['app' => 'core']); self::$_usedBackends[$backend] = new \OC\User\Database(); \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); break; @@ -102,7 +105,7 @@ class OC_User { \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); break; default: - \OCP\Server::get(LoggerInterface::class)->debug('Adding default user backend ' . $backend . '.', ['app' => 'core']); + Server::get(LoggerInterface::class)->debug('Adding default user backend ' . $backend . '.', ['app' => 'core']); $className = 'OC_USER_' . strtoupper($backend); self::$_usedBackends[$backend] = new $className(); \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); @@ -147,10 +150,10 @@ class OC_User { self::useBackend($backend); self::$_setupedBackends[] = $i; } else { - \OCP\Server::get(LoggerInterface::class)->debug('User backend ' . $class . ' already initialized.', ['app' => 'core']); + Server::get(LoggerInterface::class)->debug('User backend ' . $class . ' already initialized.', ['app' => 'core']); } } else { - \OCP\Server::get(LoggerInterface::class)->error('User backend ' . $class . ' not found.', ['app' => 'core']); + Server::get(LoggerInterface::class)->error('User backend ' . $class . ' not found.', ['app' => 'core']); } } } @@ -303,7 +306,7 @@ class OC_User { } $user = \OC::$server->getUserSession()->getUser(); - if ($user instanceof \OCP\IUser) { + if ($user instanceof IUser) { $backend = $user->getBackend(); if ($backend instanceof \OCP\User\Backend\ICustomLogout) { return $backend->getLogoutUrl(); @@ -323,12 +326,9 @@ class OC_User { * @return bool */ public static function isAdminUser($uid) { - $group = \OC::$server->getGroupManager()->get('admin'); - $user = \OC::$server->getUserManager()->get($uid); - if ($group && $user && $group->inGroup($user) && self::$incognitoMode === false) { - return true; - } - return false; + $user = Server::get(IUserManager::class)->get($uid); + $isAdmin = $user && Server::get(IGroupManager::class)->isAdmin($user->getUID()); + return $isAdmin && self::$incognitoMode === false; } |