Skip to content

Commit

Permalink
fix(files_external): basic auth user storage trigger
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv committed Oct 10, 2023
1 parent e6d0105 commit ae29608
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions apps/files_external/lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public function getUserMounts(): DataResponse {

/**
* @NoAdminRequired
* @NoCSRFRequired
*
* Ask for credentials using a browser's native basic auth prompt
* Then returns it if provided
Expand Down
8 changes: 5 additions & 3 deletions apps/files_external/src/actions/enterCredentialsAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ export const action = new FileAction({

async exec(node: Node) {
// always resolve auth request, we'll process the data afterwards
const response = await axios.get(generateOcsUrl('/apps/files_external/api/v1/auth'), {
validateStatus: () => true,
// Using fetch as axios have integrated auth handling and X-Requested-With header
const response = await fetch(generateOcsUrl('/apps/files_external/api/v1/auth'), {
headers: new Headers({ Accept: 'application/json' }),
credentials: 'include',
})

const data = (response?.data || {}) as OCSAuthResponse
const data = (await response?.json() || {}) as OCSAuthResponse
if (data.ocs.data.user && data.ocs.data.password) {
const configResponse = await axios.put(generateUrl('apps/files_external/userglobalstorages/{id}', node.attributes), {
backendOptions: data.ocs.data,
Expand Down
4 changes: 2 additions & 2 deletions dist/files_external-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_external-init.js.map

Large diffs are not rendered by default.

0 comments on commit ae29608

Please sign in to comment.