Merge pull request #46090 from nextcloud/backport/46073/stable28

[stable28] fix: allows admin to edit global credentials
This commit is contained in:
Andy Scherzinger 2024-07-11 17:06:24 +02:00 committed by GitHub
commit 290ccdb684
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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;
}
}