diff --git a/client/coral-embed/src/index.js b/client/coral-embed/src/index.js index 0a901c341..14de2756e 100644 --- a/client/coral-embed/src/index.js +++ b/client/coral-embed/src/index.js @@ -54,15 +54,11 @@ function configurePymParent(pymParent, opts) { pymParent.sendMessage('config', JSON.stringify(config)); } - function onAuthChanged(message) { + pymParent.onMessage('coral-auth-changed', function(message) { if (opts.onAuthChanged) { opts.onAuthChanged(message ? JSON.parse(message) : null); } - } - - pymParent.onMessage('coral-login', onAuthChanged); - - pymParent.onMessage('coral-logout', onAuthChanged); + }); // Sends config to the child pymParent.onMessage('getConfig', function() { diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index b7ec4ee4c..614b87632 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -285,7 +285,7 @@ export const logout = () => (dispatch) => { resetWebsocket(); dispatch({type: actions.LOGOUT}); - pym.sendMessage('coral-logout'); + pym.sendMessage('coral-auth-changed'); }); }; @@ -306,7 +306,6 @@ export const checkLogin = () => (dispatch) => { dispatch(checkLoginRequest()); coralApi('/auth') .then((result) => { - if (!result.user) { if (!bowser.safari && !bowser.ios) { Storage.removeItem('token'); @@ -318,7 +317,7 @@ export const checkLogin = () => (dispatch) => { resetWebsocket(); dispatch(checkLoginSuccess(result.user)); - pym.sendMessage('coral-login', JSON.stringify(result.user)); + pym.sendMessage('coral-auth-changed', JSON.stringify(result.user)); // Display create username dialog if necessary. if (result.user.canEditName && result.user.status !== 'BANNED') {