Skip to content

Commit 21b5b88

Browse files
committed
fix(files_external): request strict password auth on credentials enter action
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent bdc043d commit 21b5b88

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

apps/files_external/src/actions/enterCredentialsAction.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { AxiosResponse } from '@nextcloud/axios'
77
import type { Node } from '@nextcloud/files'
88
import type { StorageConfig } from '../services/externalStorage'
99

10+
import { addPasswordConfirmationInterceptors, PwdConfirmationMode } from '@nextcloud/password-confirmation'
1011
import { generateUrl } from '@nextcloud/router'
1112
import { showError, showSuccess, spawnDialog } from '@nextcloud/dialogs'
1213
import { translate as t } from '@nextcloud/l10n'
@@ -18,6 +19,10 @@ import { FileAction, DefaultType } from '@nextcloud/files'
1819
import { STORAGE_STATUS, isMissingAuthConfig } from '../utils/credentialsUtils'
1920
import { isNodeExternalStorage } from '../utils/externalStorageUtils'
2021

22+
// Add password confirmation interceptors as
23+
// the backend requires the user to confirm their password
24+
addPasswordConfirmationInterceptors(axios)
25+
2126
type CredentialResponse = {
2227
login?: string,
2328
password?: string,
@@ -31,8 +36,13 @@ type CredentialResponse = {
3136
* @param password The password
3237
*/
3338
async function setCredentials(node: Node, login: string, password: string): Promise<null|true> {
34-
const configResponse = await axios.put(generateUrl('apps/files_external/userglobalstorages/{id}', { id: node.attributes.id }), {
35-
backendOptions: { user: login, password },
39+
const configResponse = await axios.request({
40+
method: 'PUT',
41+
url: generateUrl('apps/files_external/userglobalstorages/{id}', { id: node.attributes.id }),
42+
confirmPassword: PwdConfirmationMode.Strict,
43+
data: {
44+
backendOptions: { user: login, password },
45+
},
3646
}) as AxiosResponse<StorageConfig>
3747

3848
const config = configResponse.data

0 commit comments

Comments
 (0)