-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error message when window.opener == null
#5340
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -14,11 +14,35 @@ const htmlContent = (token, origin) => { | |||||||
<head> | ||||||||
<meta charset="utf-8" /> | ||||||||
<script> | ||||||||
window.opener.postMessage(${serialize({ token })}, ${serialize(origin)}) | ||||||||
window.close() | ||||||||
'use strict'; | ||||||||
|
||||||||
function sendToken() { | ||||||||
var data = ${serialize({ token })}; | ||||||||
var origin = ${serialize(origin)}; | ||||||||
|
||||||||
Comment on lines
+20
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
if (window.opener != null) { | ||||||||
window.opener.postMessage(data, origin) | ||||||||
window.close() | ||||||||
} else { | ||||||||
// maybe this will work? (note that it's not possible to try/catch this to see whether it worked) | ||||||||
window.postMessage(data, origin) | ||||||||
|
||||||||
console.warn('Unable to send the authentication token to the web app. This probably means that the web app was served from a HTTP server that includes the \`Cross-Origin-Opener-Policy: same-origin\` header. Make sure that the Uppy app is served from a server that does not send this header, or set to \`same-origin-allow-popups\`.') | ||||||||
|
||||||||
addEventListener("DOMContentLoaded", () => { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
document.body.append(document.createTextNode('Something went wrong. Please contact the site administrator. You may now exit this page.')) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
}); | ||||||||
} | ||||||||
} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
sendToken(); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
</script> | ||||||||
</head> | ||||||||
<body></body> | ||||||||
<body> | ||||||||
<noscript> | ||||||||
JavaScript must be enabled for this to work. | ||||||||
</noscript> | ||||||||
</body> | ||||||||
</html>` | ||||||||
} | ||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.