Send post message with auth state to parent window.

This commit is contained in:
Max Eddy
2017-06-06 15:31:50 -04:00
parent 30ca7b3d64
commit 6139828844
2 changed files with 9 additions and 1 deletions
+4
View File
@@ -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 || {});
+5 -1
View File
@@ -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));
});
};