diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index 8335d38d2..a2bd50980 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -219,7 +219,7 @@ class Embed extends React.Component { :

{asset.settings.closedMessage}

} - {!loggedIn && } + {!loggedIn && } {loggedIn && user && } {loggedIn && } diff --git a/client/coral-embed-stream/src/index.js b/client/coral-embed-stream/src/index.js index 15bb959fc..d7ee99e73 100644 --- a/client/coral-embed-stream/src/index.js +++ b/client/coral-embed-stream/src/index.js @@ -3,10 +3,12 @@ import {render} from 'react-dom'; import {ApolloProvider} from 'react-apollo'; import {client} from 'coral-framework/services/client'; -import store from 'coral-framework/services/store'; +import localStore from 'coral-framework/services/store'; import AppRouter from './AppRouter'; +const store = (window.opener && window.opener.coralStore) ? window.opener.coralStore : localStore; + render( diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index 199c98534..916f93540 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -26,16 +26,19 @@ export const showSignInDialog = () => dispatch => { const signInPopUp = window.open( '/embed/stream/login', 'Login', - 'menubar=0,resizable=0,width=500,height=500,top=200,left=500' + 'menubar=0,resizable=0,width=500,height=550,top=200,left=500' ); - signInPopUp.onbeforeunload = fetchMe; - // ({type: actions.SHOW_SIGNIN_DIALOG, offset}) + signInPopUp.onbeforeunload = () => { + dispatch(checkLogin()); + fetchMe(); + }; + dispatch({type: actions.SHOW_SIGNIN_DIALOG}); }; export const hideSignInDialog = () => dispatch => { + dispatch({type: actions.HIDE_SIGNIN_DIALOG}); window.close(); - // ({type: actions.HIDE_SIGNIN_DIALOG}); -} +}; export const createUsernameRequest = () => ({type: actions.CREATE_USERNAME_REQUEST}); export const showCreateUsernameDialog = () => ({type: actions.SHOW_CREATEUSERNAME_DIALOG}); @@ -62,10 +65,13 @@ export const createUsername = (userId, formData) => dispatch => { export const changeView = view => dispatch => { switch(view) { case 'SIGNUP': - window.resizeTo(500, 700); + window.resizeTo(500, 800); + break; + case 'FORGOT': + window.resizeTo(500, 400); break; default: - window.resizeTo(500, 500); + window.resizeTo(500, 550); } dispatch({ type: actions.CHANGE_VIEW, @@ -87,7 +93,7 @@ const signInFailure = error => ({type: actions.FETCH_SIGNIN_FAILURE, error}); export const fetchSignIn = (formData) => (dispatch) => { dispatch(signInRequest()); return coralApi('/auth/local', {method: 'POST', body: formData}) - .then(() => dispatch(closeSignInPopUp())) + .then(() => dispatch(hideSignInDialog())) .catch(error => { if (error.metadata) { @@ -101,22 +107,6 @@ export const fetchSignIn = (formData) => (dispatch) => { }); }; -// Sign In - Standalone PopUp - -export const openSignInPopUp = cb => () => { - const signInPopUp = window.open( - '/embed/stream/login', - 'Login', - 'menubar=0,resizable=0,width=500,height=500,top=200,left=500' - ); - - signInPopUp.onbeforeunload = cb; -}; - -export const closeSignInPopUp = () => () => { - window.close(); -}; - // Sign In - Facebook const signInFacebookRequest = () => ({type: actions.FETCH_SIGNIN_FACEBOOK_REQUEST}); @@ -155,7 +145,7 @@ export const facebookCallback = (err, data) => dispatch => { dispatch(signInFacebookSuccess(user)); dispatch(hideSignInDialog()); dispatch(showCreateUsernameDialog()); - fetchMe(); + dispatch(hideSignInDialog()); } catch (err) { dispatch(signInFacebookFailure(err)); return; diff --git a/client/coral-framework/reducers/auth.js b/client/coral-framework/reducers/auth.js index f9712c937..6e678cab9 100644 --- a/client/coral-framework/reducers/auth.js +++ b/client/coral-framework/reducers/auth.js @@ -28,8 +28,7 @@ export default function auth (state = initialState, action) { switch (action.type) { case actions.SHOW_SIGNIN_DIALOG : return state - .set('showSignInDialog', true) - .set('signInOffset', action.offset); + .set('showSignInDialog', true); case actions.HIDE_SIGNIN_DIALOG : return state.merge(Map({ isLoading: false, diff --git a/client/coral-framework/services/store.js b/client/coral-framework/services/store.js index fbc444eec..d7090f4b5 100644 --- a/client/coral-framework/services/store.js +++ b/client/coral-framework/services/store.js @@ -24,7 +24,7 @@ if (window.devToolsExtension) { middlewares.push(window.devToolsExtension()); } -export default createStore( +const store = createStore( combineReducers({ ...mainReducer, apollo: client.reducer() @@ -32,3 +32,6 @@ export default createStore( {}, compose(...middlewares) ); + +export default store; +window.coralStore = store;