diff --git a/client/coral-embed/src/index.js b/client/coral-embed/src/index.js index d90591f2f..c6c29c30e 100644 --- a/client/coral-embed/src/index.js +++ b/client/coral-embed/src/index.js @@ -54,9 +54,9 @@ function configurePymParent(pymParent, opts) { pymParent.sendMessage('config', JSON.stringify(config)); } - pymParent.onMessage('checkLogin', function(result) { - if (opts.onAuthChange) { - opts.onAuthChange(JSON.parse(result)); + pymParent.onMessage('coral-check-login', function(result) { + if (opts.onCheckLogin) { + opts.onCheckLogin(JSON.parse(result)); } }); diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index e4871a7e2..13a1bc24e 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -301,10 +301,12 @@ const checkLoginSuccess = (user, isAdmin) => ({ isAdmin }); -export const checkLogin = () => (dispatch, getState) => { +export const checkLogin = () => (dispatch) => { dispatch(checkLoginRequest()); coralApi('/auth') .then((result) => { + pym.sendMessage('coral-check-login', JSON.stringify(result)); + if (!result.user) { if (!bowser.safari && !bowser.ios) { Storage.removeItem('token'); @@ -325,9 +327,6 @@ export const checkLogin = () => (dispatch, getState) => { .catch((error) => { console.error(error); dispatch(checkLoginFailure(`${error.translation_key}`)); - }) - .then(() => { - pym.sendMessage('checkLogin', JSON.stringify(getState().auth)); }); };