From cfcfe39bb729de941668c7c772c28f9c77109c60 Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Wed, 1 Feb 2017 08:25:15 +0200 Subject: [PATCH] Completly reset all auth state on header logo click --- src/components/auth/actions.js | 12 ++++++++++++ src/pages/root/RootPage.jsx | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/components/auth/actions.js b/src/components/auth/actions.js index 41dd32a..d87552c 100644 --- a/src/components/auth/actions.js +++ b/src/components/auth/actions.js @@ -286,6 +286,18 @@ export function resetOAuth() { }; } +/** + * Resets all temporary state related to auth + * + * @return {function} + */ +export function resetAuth() { + return (dispatch) => { + dispatch(setLogin(null)); + dispatch(resetOAuth({})); + }; +} + export const SET_OAUTH = 'set_oauth'; export function setOAuthRequest(oauth) { return { diff --git a/src/pages/root/RootPage.jsx b/src/pages/root/RootPage.jsx index 1d2f2a4..5d879ee 100644 --- a/src/pages/root/RootPage.jsx +++ b/src/pages/root/RootPage.jsx @@ -31,7 +31,7 @@ function RootPage(props) { })}>
- +
@@ -57,16 +57,16 @@ RootPage.propTypes = { pathname: PropTypes.string }).isRequired, children: PropTypes.element, - resetOAuth: PropTypes.func.isRequired, + resetAuth: PropTypes.func.isRequired, isPopupActive: PropTypes.bool.isRequired }; import { connect } from 'react-redux'; -import { resetOAuth } from 'components/auth/actions'; +import { resetAuth } from 'components/auth/actions'; export default connect((state) => ({ user: state.user, isPopupActive: state.popup.popups.length > 0 }), { - resetOAuth + resetAuth })(RootPage);