Skip to content

Instantly share code, notes, and snippets.

@dinkydani
Last active June 16, 2020 17:33
Show Gist options
  • Save dinkydani/b9b534ce00186436442b5a5996ee87dd to your computer and use it in GitHub Desktop.
Save dinkydani/b9b534ce00186436442b5a5996ee87dd to your computer and use it in GitHub Desktop.
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
const { payload } = data;
const redirectUrl = `/auth/google/login${payload}`;
window.location.pathname = redirectUrl;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment