From 613982884479bb53ff55f220973c36868f13cc88 Mon Sep 17 00:00:00 2001 From: Max Eddy Date: Tue, 6 Jun 2017 15:31:50 -0400 Subject: [PATCH] Send post message with auth state to parent window. --- client/coral-embed/src/index.js | 4 ++++ client/coral-framework/actions/auth.js | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/client/coral-embed/src/index.js b/client/coral-embed/src/index.js index 65e77ad1d..47c761bd3 100644 --- a/client/coral-embed/src/index.js +++ b/client/coral-embed/src/index.js @@ -54,6 +54,10 @@ function configurePymParent(pymParent, opts) { pymParent.sendMessage('config', JSON.stringify(config)); } + pymParent.onMessage('checkLogin', function(result) { + console.log(JSON.parse(result)); + }); + // Sends config to the child pymParent.onMessage('getConfig', function() { sendConfig(opts || {}); diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index eaaee3034..e4871a7e2 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -3,6 +3,7 @@ import bowser from 'bowser'; import * as actions from '../constants/auth'; import * as Storage from '../helpers/storage'; import coralApi, {base} from '../helpers/request'; +import pym from '../services/PymConnection'; import {resetWebsocket} from 'coral-framework/services/client'; import t from 'coral-framework/services/i18n'; @@ -300,7 +301,7 @@ const checkLoginSuccess = (user, isAdmin) => ({ isAdmin }); -export const checkLogin = () => (dispatch) => { +export const checkLogin = () => (dispatch, getState) => { dispatch(checkLoginRequest()); coralApi('/auth') .then((result) => { @@ -324,6 +325,9 @@ export const checkLogin = () => (dispatch) => { .catch((error) => { console.error(error); dispatch(checkLoginFailure(`${error.translation_key}`)); + }) + .then(() => { + pym.sendMessage('checkLogin', JSON.stringify(getState().auth)); }); };