*/
protected function getUserData(string $userId, bool $includeScopes = false): array {
$currentLoggedInUser = $this->userSession->getUser();
+ assert($currentLoggedInUser !== null, 'No user logged in');
$data = [];
throw new OCSNotFoundException('User does not exist');
}
- // Should be at least Admin Or SubAdmin!
- if ($this->groupManager->isAdmin($currentLoggedInUser->getUID())
+ $isAdmin = $this->groupManager->isAdmin($currentLoggedInUser->getUID());
+ if ($isAdmin
|| $this->groupManager->getSubAdmin()->isUserAccessible($currentLoggedInUser, $targetUserObject)) {
$data['enabled'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true') === 'true';
} else {
$gids[] = $group->getGID();
}
- try {
- # might be thrown by LDAP due to handling of users disappears
- # from the external source (reasons unknown to us)
- # cf. https://github.com/nextcloud/server/issues/12991
- $data['storageLocation'] = $targetUserObject->getHome();
- } catch (NoUserException $e) {
- throw new OCSNotFoundException($e->getMessage(), $e);
+ if ($isAdmin) {
+ try {
+ # might be thrown by LDAP due to handling of users disappears
+ # from the external source (reasons unknown to us)
+ # cf. https://github.com/nextcloud/server/issues/12991
+ $data['storageLocation'] = $targetUserObject->getHome();
+ } catch (NoUserException $e) {
+ throw new OCSNotFoundException($e->getMessage(), $e);
+ }
}
// Find the data
->method('getDisplayName')
->willReturn('Demo User');
$targetUser
- ->expects($this->once())
- ->method('getHome')
- ->willReturn('/var/www/newtcloud/data/UID');
+ ->expects($this->never())
+ ->method('getHome');
$targetUser
->expects($this->once())
->method('getLastLogin')
$expected = [
'id' => 'UID',
'enabled' => true,
- 'storageLocation' => '/var/www/newtcloud/data/UID',
'lastLogin' => 1521191471000,
'backend' => 'Database',
'subadmin' => [],
->method('getUID')
->willReturn('UID');
$targetUser
- ->expects($this->once())
- ->method('getHome')
- ->willReturn('/var/www/newtcloud/data/UID');
+ ->expects($this->never())
+ ->method('getHome');
$targetUser
->expects($this->once())
->method('getLastLogin')
$expected = [
'id' => 'UID',
- 'storageLocation' => '/var/www/newtcloud/data/UID',
'lastLogin' => 1521191471000,
'backend' => 'Database',
'subadmin' => [],