aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2019-09-09 17:14:21 +0200
committerBackportbot <backportbot-noreply@rullzer.com>2019-09-10 14:02:04 +0000
commit1a7ed9ae81aed3e106367320ccc14db7309d41ef (patch)
treeffe77377fd6d23a74128cec8c09b046fdf27d886
parente1ee36b4e8786c41eba95651f5a8cc1e56c62293 (diff)
downloadnextcloud-server-1a7ed9ae81aed3e106367320ccc14db7309d41ef.tar.gz
nextcloud-server-1a7ed9ae81aed3e106367320ccc14db7309d41ef.zip
allow setting user provided global credentials trough credentials popup
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--apps/files_external/js/statusmanager.js5
-rw-r--r--apps/files_external/lib/Controller/UserGlobalStoragesController.php3
-rw-r--r--apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php11
3 files changed, 15 insertions, 4 deletions
diff --git a/apps/files_external/js/statusmanager.js b/apps/files_external/js/statusmanager.js
index bd423192521..0c0c8b36c74 100644
--- a/apps/files_external/js/statusmanager.js
+++ b/apps/files_external/js/statusmanager.js
@@ -93,7 +93,8 @@ OCA.Files_External.StatusManager = {
status: statusCode,
id: mountData.id,
error: statusMessage,
- userProvided: response.userProvided
+ userProvided: response.userProvided,
+ authMechanism: response.authMechanism
};
}
afterCallback(mountData, self.mountStatus[mountData.mount_point]);
@@ -178,7 +179,7 @@ OCA.Files_External.StatusManager = {
if (allMountStatus.hasOwnProperty(name) && allMountStatus[name].status > 0 && allMountStatus[name].status < 7) {
var mountData = allMountStatus[name];
if (mountData.type === "system") {
- if (mountData.userProvided) {
+ if (mountData.userProvided || mountData.authMechanism === 'password::global::user') {
// personal mount whit credentials problems
this.showCredentialsDialog(name, mountData);
} else {
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');