Skip to content

Commit

Permalink
Merge pull request #46091 from nextcloud/backport/46073/stable29
Browse files Browse the repository at this point in the history
[stable29] fix: allows admin to edit global credentials
  • Loading branch information
AndyScherzinger authored Jul 10, 2024
2 parents db748b4 + a631733 commit 7c088bd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions apps/files_external/lib/Controller/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,21 @@ public function getSshKeys($keyLength = 1024) {
*/
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;
}
}

0 comments on commit 7c088bd

Please sign in to comment.