diff options
author | skjnldsv <skjnldsv@protonmail.com> | 2025-03-07 14:22:25 +0100 |
---|---|---|
committer | skjnldsv <skjnldsv@protonmail.com> | 2025-03-11 11:38:07 +0100 |
commit | 07264dff12c1671cab5bc0b76198a2708e09d0b0 (patch) | |
tree | 875365fc9521e267a9350b30b6a660a82c27293a /apps/files_external/lib | |
parent | 21c09e4816cd76288a5d73d2910bde989bc814ae (diff) | |
download | nextcloud-server-07264dff12c1671cab5bc0b76198a2708e09d0b0.tar.gz nextcloud-server-07264dff12c1671cab5bc0b76198a2708e09d0b0.zip |
fix(external_storage): fix settings save
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r-- | apps/files_external/lib/Controller/AjaxController.php | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/apps/files_external/lib/Controller/AjaxController.php b/apps/files_external/lib/Controller/AjaxController.php index 3332044c948..4d5497b73cb 100644 --- a/apps/files_external/lib/Controller/AjaxController.php +++ b/apps/files_external/lib/Controller/AjaxController.php @@ -9,10 +9,12 @@ namespace OCA\Files_External\Controller; use OCA\Files_External\Lib\Auth\Password\GlobalAuth; use OCA\Files_External\Lib\Auth\PublicKey\RSA; use OCP\AppFramework\Controller; +use OCP\AppFramework\Http; use OCP\AppFramework\Http\Attribute\NoAdminRequired; use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IGroupManager; +use OCP\IL10N; use OCP\IRequest; use OCP\IUserSession; @@ -32,6 +34,7 @@ class AjaxController extends Controller { private GlobalAuth $globalAuth, private IUserSession $userSession, private IGroupManager $groupManager, + private IL10N $l10n, ) { parent::__construct($appName, $request); } @@ -56,27 +59,30 @@ class AjaxController extends Controller { #[NoAdminRequired] public function getSshKeys($keyLength = 1024) { $key = $this->generateSshKeys($keyLength); - return new JSONResponse( - ['data' => [ + return new JSONResponse([ + 'data' => [ 'private_key' => $key['privatekey'], 'public_key' => $key['publickey'] ], - 'status' => 'success' - ]); + 'status' => 'success', + ]); } /** * @param string $uid * @param string $user * @param string $password - * @return bool + * @return JSONResponse */ #[NoAdminRequired] #[PasswordConfirmationRequired(strict: true)] - public function saveGlobalCredentials($uid, $user, $password) { + public function saveGlobalCredentials($uid, $user, $password): JSONResponse { $currentUser = $this->userSession->getUser(); if ($currentUser === null) { - return false; + return new JSONResponse([ + 'status' => 'error', + 'message' => $this->l10n->t('You are not logged in'), + ], Http::STATUS_UNAUTHORIZED); } // Non-admins can only edit their own credentials @@ -87,9 +93,14 @@ class AjaxController extends Controller { if ($allowedToEdit) { $this->globalAuth->saveAuth($uid, $user, $password); - return true; + return new JSONResponse([ + 'status' => 'success', + ]); } - return false; + return new JSONResponse([ + 'status' => 'success', + 'message' => $this->l10n->t('Permission denied'), + ], Http::STATUS_FORBIDDEN); } } |