Skip to content

Commit eccf4dc

Browse files
committed
allow setting user provided global credentials trough credentials popup
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 1d51b29 commit eccf4dc

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

apps/files_external/js/statusmanager.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ OCA.Files_External.StatusManager = {
9393
status: statusCode,
9494
id: mountData.id,
9595
error: statusMessage,
96-
userProvided: response.userProvided
96+
userProvided: response.userProvided,
97+
authMechanism: response.authMechanism
9798
};
9899
}
99100
afterCallback(mountData, self.mountStatus[mountData.mount_point]);
@@ -178,7 +179,7 @@ OCA.Files_External.StatusManager = {
178179
if (allMountStatus.hasOwnProperty(name) && allMountStatus[name].status > 0 && allMountStatus[name].status < 7) {
179180
var mountData = allMountStatus[name];
180181
if (mountData.type === "system") {
181-
if (mountData.userProvided) {
182+
if (mountData.userProvided || mountData.authMechanism === 'password::global::user') {
182183
// personal mount whit credentials problems
183184
this.showCredentialsDialog(name, mountData);
184185
} else {

apps/files_external/lib/Controller/UserGlobalStoragesController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
use OCA\Files_External\Lib\Auth\AuthMechanism;
2929
use OCA\Files_External\Lib\Auth\IUserProvided;
30+
use OCA\Files_External\Lib\Auth\Password\UserGlobalAuth;
3031
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
3132
use OCP\ILogger;
3233
use \OCP\IRequest;
@@ -156,7 +157,7 @@ public function update(
156157
try {
157158
$storage = $this->service->getStorage($id);
158159
$authMechanism = $storage->getAuthMechanism();
159-
if ($authMechanism instanceof IUserProvided) {
160+
if ($authMechanism instanceof IUserProvided || $authMechanism instanceof UserGlobalAuth) {
160161
$authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions);
161162
$authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
162163
} else {

apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ public function __construct(IL10N $l, ICredentialsManager $credentialsManager) {
4949
->setText($l->t('Global credentials, user entered'));
5050
}
5151

52+
public function saveBackendOptions(IUser $user, $id, $backendOptions) {
53+
// make sure we're not setting any unexpected keys
54+
$credentials = [
55+
'user' => $backendOptions['user'],
56+
'password' => $backendOptions['password'],
57+
];
58+
$this->credentialsManager->store($user->getUID(), self::CREDENTIALS_IDENTIFIER, $credentials);
59+
}
60+
5261
public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
5362
if ($user === null) {
5463
throw new InsufficientDataForMeaningfulAnswerException('No credentials saved');

0 commit comments

Comments
 (0)