Skip to content

Commit

Permalink
fix: public link download in authenticated context
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Feb 19, 2024
1 parent 6fca4f4 commit 2c60aeb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-public-link-file-download
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Public link file download

We've fixed a bug where the download of a file from a public link was not working when the user had logged in already. The download only worked if no user was logged in.

https://github.com/owncloud/web/issues/10473
https://github.com/owncloud/web/pull/10494
27 changes: 18 additions & 9 deletions packages/web-pkg/src/composables/download/useDownloadFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,27 @@ export const useDownloadFile = (options?: DownloadFileOptions) => {
const { owncloudSdk: client } = clientService
const isUserContext = store.getters['runtime/auth/isUserContextReady']

// construct the url and headers
let url
if (unref(isPublicLinkContext)) {
url = file.downloadURL
} else {
if (version === null) {
url = `${client.helpers._davPath}${file.webDavPath}`
} else {
url = client.fileVersions.getFileVersionUrl(file.fileId, version)
// public links have a pre-signed download url
if (file.downloadURL) {
try {
triggerDownloadWithFilename(file.downloadURL, file.name)
} catch (e) {
console.error(e)
store.dispatch('showErrorMessage', {
title: $gettext('Download failed'),
desc: $gettext('File could not be located'),
errors: [e]
})
}
return
}

// construct the download url
const url =
version === null
? `${client.helpers._davPath}${file.webDavPath}`
: client.fileVersions.getFileVersionUrl(file.fileId, version)

// download with signing enabled
if (isUserContext && unref(isUrlSigningEnabled)) {
const httpClient = clientService.httpAuthenticated
Expand Down

0 comments on commit 2c60aeb

Please sign in to comment.