Skip to content

Commit

Permalink
@uppy/companion-client: do not reject login promise on events from in…
Browse files Browse the repository at this point in the history
…correct source

While these events should be ignored they might be unrelated and should not reject the whole login
  • Loading branch information
dschmidt committed Aug 2, 2023
1 parent ce7f90e commit 2efc047
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/@uppy/companion-client/src/Provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,14 @@ export default class Provider extends RequestClient {
const authWindow = window.open(link, '_blank')
const handleToken = (e) => {
if (e.source !== authWindow) {
reject(new Error('rejecting event from unknown source'))
this.uppy.log.warn('ignoring event from unknown source', e)
return
}

const { companionAllowedHosts } = this.uppy.getPlugin(this.pluginId).opts
if (!isOriginAllowed(e.origin, companionAllowedHosts) || e.source !== authWindow) {
if (!isOriginAllowed(e.origin, companionAllowedHosts)) {
reject(new Error(`rejecting event from ${e.origin} vs allowed pattern ${companionAllowedHosts}`))
return
}

// Check if it's a string before doing the JSON.parse to maintain support
Expand Down

0 comments on commit 2efc047

Please sign in to comment.