Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/provisioning_api/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ public function editUser(string $userId, string $key, string $value): DataRespon
} else {
// Check if admin / subadmin
$subAdminManager = $this->groupManager->getSubAdmin();
if ($subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
|| $this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
if ($this->groupManager->isAdmin($currentLoggedInUser->getUID())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice turn around 👍

|| $subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
// They have permissions over the user
$permittedFields[] = 'display';
$permittedFields[] = AccountManager::PROPERTY_DISPLAYNAME;
Expand Down
23 changes: 16 additions & 7 deletions lib/private/SubAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,22 @@ public function isUserAccessible(IUser $subadmin, IUser $user): bool {
if($this->groupManager->isAdmin($user->getUID())) {
return false;
}
$accessibleGroups = $this->getSubAdminsGroups($subadmin);
foreach($accessibleGroups as $accessibleGroup) {
if($accessibleGroup->inGroup($user)) {
return true;
}
}
return false;

$qb = $this->dbConn->getQueryBuilder();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works with the default groups backend, so this is not possible. But I have another idea in mind to make this faster

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works with the default groups backend, so this is not possible. But I have another idea in mind to make this faster

Ah you are right. I did not think about that. If you point me in a direction I can look into it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supposedly, fetch the user's groups and check whether there is an overlap.


$result = $qb->select('gm.uid')
->from('group_admin', 'ga')
->join('ga', 'group_admin', 'gm', 'ga.gid = gm.gid')
->andWhere($qb->expr()->eq('ga.uid', $qb->createNamedParameter($subadmin->getUID())))
->andWhere($qb->expr()->eq('gm.uid', $qb->createNamedParameter($user->getUID())))
->setMaxResults(1)
->execute();
;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
;


$isUserAccessible = $result->fetch();
$result->closeCursor();

return $isUserAccessible !== false;
}

/**
Expand Down