fix: allows admin to edit global credentials

Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
This commit is contained in:
Benjamin Gaussorgues 2024-06-24 14:49:09 +02:00 committed by Andy Scherzinger
parent 127ea972bc
commit c7082d5fb8

View file

@ -106,15 +106,21 @@ class AjaxController extends Controller {
*/
public function saveGlobalCredentials($uid, $user, $password) {
$currentUser = $this->userSession->getUser();
if ($currentUser === null) {
return false;
}
// Non-admins can only edit their own credentials
$allowedToEdit = ($currentUser->getUID() === $uid);
// Admin can edit global credentials
$allowedToEdit = $uid === ''
? $this->groupManager->isAdmin($currentUser->getUID())
: $currentUser->getUID() === $uid;
if ($allowedToEdit) {
$this->globalAuth->saveAuth($uid, $user, $password);
return true;
} else {
return false;
}
return false;
}
}