Skip to content

Commit

Permalink
@uppy/companion-client,@uppy/provider-views: make authentication opti…
Browse files Browse the repository at this point in the history
…onal in ProviderView
  • Loading branch information
dschmidt committed Jul 6, 2023
1 parent ded685e commit b7ab2c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/@uppy/companion-client/src/Provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default class Provider extends RequestClient {
this.tokenKey = `companion-${this.pluginId}-auth-token`
this.companionKeysParams = this.opts.companionKeysParams
this.preAuthToken = null
this.authentication = opts.authentication ?? true
}

async headers () {
Expand Down Expand Up @@ -136,6 +137,9 @@ export default class Provider extends RequestClient {
}

async logout () {
if (!this.authentication) {
return Promise.resolve({ ok: true, revoked: true })
}
const response = await this.get(`${this.id}/logout`)
await this.#removeAuthToken()
return response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ export default class ProviderView extends View {
}

async handleAuth () {
if (!this.provider.authentication) {
this.plugin.setPluginState({ authenticated: true })
this.preFirstRender()
return
}

await this.provider.ensurePreAuth()

const authState = btoa(JSON.stringify({ origin: getOrigin() }))
Expand Down

0 comments on commit b7ab2c5

Please sign in to comment.