From 4777c4aacaa9bee51d9199fa0be5eabe64aa76ce Mon Sep 17 00:00:00 2001 From: Bogdan Cochior <bogdan.cochior@thinslices.com> Date: Tue, 10 Jul 2018 16:38:07 +0300 Subject: [PATCH] fix(login): logout user if access login page --- .../src/components/Login/LoginPage.js | 17 +++++++++++++++++ packages/xpub-faraday/app/routes.js | 5 +---- 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 packages/components-faraday/src/components/Login/LoginPage.js diff --git a/packages/components-faraday/src/components/Login/LoginPage.js b/packages/components-faraday/src/components/Login/LoginPage.js new file mode 100644 index 000000000..6ea37a256 --- /dev/null +++ b/packages/components-faraday/src/components/Login/LoginPage.js @@ -0,0 +1,17 @@ +import Login from 'pubsweet-component-login/LoginContainer' +import { connect } from 'react-redux' +import { withProps, lifecycle, compose } from 'recompose' +import { actions } from 'pubsweet-client' + +const LoginPage = compose( + connect(null, { logoutUser: actions.logoutUser }), + withProps({ passwordReset: true }), + lifecycle({ + componentDidMount() { + const { logoutUser } = this.props + logoutUser() + }, + }), +)(Login) + +export default LoginPage diff --git a/packages/xpub-faraday/app/routes.js b/packages/xpub-faraday/app/routes.js index f30eeddbf..ae7f6e640 100644 --- a/packages/xpub-faraday/app/routes.js +++ b/packages/xpub-faraday/app/routes.js @@ -1,12 +1,11 @@ import React from 'react' -import { withProps } from 'recompose' import { Route, Switch } from 'react-router-dom' import { AuthenticatedComponent } from 'pubsweet-client' -import Login from 'pubsweet-component-login/LoginContainer' import { Wizard } from 'pubsweet-component-wizard/src/components' import { ManuscriptPage } from 'pubsweet-component-manuscript/src/components' import DashboardPage from 'pubsweet-components-faraday/src/components/Dashboard' +import LoginPage from 'pubsweet-components-faraday/src/components/Login/LoginPage' import { NotFound, InfoPage, @@ -27,8 +26,6 @@ import { import FaradayApp from './FaradayApp' -const LoginPage = withProps({ passwordReset: true })(Login) - const PrivateRoute = ({ component: Component, ...rest }) => ( <Route {...rest} -- GitLab