Skip to content

Commit

Permalink
Fix option type for public token
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Nov 5, 2021
1 parent 6dbda47 commit 6ced5fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions packages/web-app-external/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,24 @@ export default {
await unauthenticatedUserReady(this.$router, this.$store)
this.loading = true
const publicLinkPassword = this.publicLinkPassword
// build headers with respect to the actual auth situation
const { 'public-token': publicToken } = this.$route.query
const token = this.getToken
const publicLinkPassword = this.publicLinkPassword
const accessToken = this.getToken
const headers = {
'X-Requested-With': 'XMLHttpRequest',
...(publicToken && { 'public-token': publicToken }),
...(publicLinkPassword && {
Authorization:
'Basic ' + Buffer.from(['public', publicLinkPassword].join(':')).toString('base64')
}),
...(token && {
Authorization: 'Bearer ' + token
...(accessToken && {
Authorization: 'Bearer ' + accessToken
})
}
// fetch iframe params for app and file
const configUrl = this.configuration.server
const appOpenUrl = this.capabilities.files.app_providers[0].open_url.replace('/app', 'app')
const url = configUrl + appOpenUrl + '?file_id=' + this.fileId + '&app_name=' + this.appName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface TriggerDownloadAsArchiveOptions {
fileIds: string[]
archiverService?: ArchiverService
clientService?: ClientService
publicToken?: ClientService
publicToken?: string
}

export const triggerDownloadAsArchive = async (
Expand All @@ -35,8 +35,8 @@ export const triggerDownloadAsArchive = async (
}

const queryParams = [
...options.fileIds.map((id) => `id=${id}`),
options.publicToken ? `public-token=${options.publicToken}` : ''
options.publicToken ? `public-token=${options.publicToken}` : '',
...options.fileIds.map((id) => `id=${id}`)
].filter(Boolean)
const archiverUrl = archiverService.url + '?' + queryParams.join('&')

Expand Down

0 comments on commit 6ced5fc

Please sign in to comment.