From 09170671f96107a01b1005cc3b57253d69b31f5d Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 26 Feb 2018 17:29:53 +0100 Subject: [PATCH] Remove redudant request for user object --- .../coral-embed-stream/src/containers/Embed.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/client/coral-embed-stream/src/containers/Embed.js b/client/coral-embed-stream/src/containers/Embed.js index acdbb184b..812c18e22 100644 --- a/client/coral-embed-stream/src/containers/Embed.js +++ b/client/coral-embed-stream/src/containers/Embed.js @@ -33,7 +33,7 @@ import { setActiveTab } from '../actions/embed'; import { HANDLE_SUCCESSFUL_LOGIN } from 'coral-framework/constants/auth'; import { handleSuccessfulLogin, - checkLogin, + setAuthToken, } from 'coral-framework/actions/auth'; import { subscribeToMessages, @@ -110,10 +110,15 @@ class EmbedContainer extends React.Component { // data will contain the user and token. const { user, token } = data; - const { handleSuccessfulLogin, checkLogin } = this.props; + const { handleSuccessfulLogin, setAuthToken } = this.props; - handleSuccessfulLogin(user, token); - checkLogin(); + if (user && token) { + handleSuccessfulLogin(user, token); + } else if (token) { + setAuthToken(token); + } else { + console.error('Invalid auth data supplied', data); + } }; resubscribe(props) { @@ -330,7 +335,7 @@ EmbedContainer.propTypes = { showSignInDialog: PropTypes.bool, signInDialogFocus: PropTypes.bool, handleSuccessfulLogin: PropTypes.func.isRequired, - checkLogin: PropTypes.func.isRequired, + setAuthToken: PropTypes.func.isRequired, }; const mapStateToProps = state => ({ @@ -359,7 +364,7 @@ const mapDispatchToProps = dispatch => hideSignInDialog, updateStatus, handleSuccessfulLogin, - checkLogin, + setAuthToken, }, dispatch );