Merge pull request #590 from coralproject/auth-login-fixes

Auth login fixes
This commit is contained in:
Belén Curcio
2017-05-16 07:42:32 -03:00
committed by GitHub
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -267,8 +267,8 @@ export const fetchForgotPassword = (email) => (dispatch) => {
export const logout = () => (dispatch) => {
return coralApi('/auth', {method: 'DELETE'}).then(() => {
dispatch({type: actions.LOGOUT});
Storage.removeItem('token');
dispatch({type: actions.LOGOUT});
});
};
@@ -25,6 +25,14 @@ class ProfileContainer extends Component {
};
}
componentWillReceiveProps(nextProps) {
if (this.props.auth.loggedIn !== nextProps.auth.loggedIn) {
// Refetch after login/logout.
this.props.data.refetch();
}
}
handleTabChange = (tab) => {
this.setState({
activeTab: tab
@@ -39,7 +47,7 @@ class ProfileContainer extends Component {
return <NotLoggedIn showSignInDialog={showSignInDialog} />;
}
if (data.loading) {
if (!me || data.loading) {
return <Spinner />;
}