diff options
author | Robin Appelman <robin@icewind.nl> | 2019-09-09 18:14:21 +0300 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2019-09-09 18:15:30 +0300 |
commit | 603655341e12f84abc9a26f298478838c7b300ea (patch) | |
tree | c80aec493c1ad12e91fd66a8f0803686e5ce9c6e /apps/files_external/lib | |
parent | 1d51b297a908d427016983b45924834f6dfd95c7 (diff) |
allow setting user provided global credentials trough credentials popup
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r-- | apps/files_external/lib/Controller/UserGlobalStoragesController.php | 3 | ||||
-rw-r--r-- | apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php | 11 |
2 files changed, 12 insertions, 2 deletions
diff --git a/apps/files_external/lib/Controller/UserGlobalStoragesController.php b/apps/files_external/lib/Controller/UserGlobalStoragesController.php index 22c9c867855..55d079e9c69 100644 --- a/apps/files_external/lib/Controller/UserGlobalStoragesController.php +++ b/apps/files_external/lib/Controller/UserGlobalStoragesController.php @@ -27,6 +27,7 @@ namespace OCA\Files_External\Controller; use OCA\Files_External\Lib\Auth\AuthMechanism; use OCA\Files_External\Lib\Auth\IUserProvided; +use OCA\Files_External\Lib\Auth\Password\UserGlobalAuth; use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException; use OCP\ILogger; use \OCP\IRequest; @@ -156,7 +157,7 @@ class UserGlobalStoragesController extends StoragesController { try { $storage = $this->service->getStorage($id); $authMechanism = $storage->getAuthMechanism(); - if ($authMechanism instanceof IUserProvided) { + if ($authMechanism instanceof IUserProvided || $authMechanism instanceof UserGlobalAuth) { $authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions); $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); } else { diff --git a/apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php b/apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php index 6326830f020..8ea9ad0f785 100644 --- a/apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php +++ b/apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php @@ -44,11 +44,20 @@ class UserGlobalAuth extends AuthMechanism { $this ->setIdentifier('password::global::user') - ->setVisibility(BackendService::VISIBILITY_ADMIN) + ->setVisibility(BackendService::VISIBILITY_DEFAULT) ->setScheme(self::SCHEME_PASSWORD) ->setText($l->t('Global credentials, user entered')); } + public function saveBackendOptions(IUser $user, $id, $backendOptions) { + // make sure we're not setting any unexpected keys + $credentials = [ + 'user' => $backendOptions['user'], + 'password' => $backendOptions['password'], + ]; + $this->credentialsManager->store($user->getUID(), self::CREDENTIALS_IDENTIFIER, $credentials); + } + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { if ($user === null) { throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |