This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const receiveMessage = event => { | |
// Do we trust the sender of this message? (might be | |
// different from what we originally opened, for example). | |
if (event.origin !== BASE_URL) { | |
return; | |
} | |
const { data } = event; | |
// if we trust the sender and the source is our popup | |
if (data.source === 'lma-login-redirect') { | |
// get the URL params and redirect to our server to use Passport to auth/login |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default () => { | |
useEffect(() => { | |
// get the URL parameters which will include the auth token | |
const params = window.location.search; | |
if (window.opener) { | |
// send them to the opening window | |
window.opener.postMessage(params); | |
// close the popup | |
window.close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let windowObjectReference = null; | |
let previousUrl = null; | |
const openSignInWindow = (url, name) => { | |
// remove any existing event listeners | |
window.removeEventListener('message', receiveMessage); | |
// window features | |
const strWindowFeatures = | |
'toolbar=no, menubar=no, width=600, height=700, top=100, left=100'; |