diff --git a/frontend/components/AuthenticatedRoutes/AuthenticatedRoutes.tests.jsx b/frontend/components/AuthenticatedRoutes/AuthenticatedRoutes.tests.jsx
index 98632f370e..9f72ce0e9e 100644
--- a/frontend/components/AuthenticatedRoutes/AuthenticatedRoutes.tests.jsx
+++ b/frontend/components/AuthenticatedRoutes/AuthenticatedRoutes.tests.jsx
@@ -17,7 +17,7 @@ describe('AuthenticatedRoutes - component', () => {
type: '@@router/CALL_HISTORY_METHOD',
payload: {
method: 'push',
- args: ['/reset_password'],
+ args: ['/login/reset'],
},
};
const renderedText = 'This text was rendered';
diff --git a/frontend/components/LoginRoutes/LoginRoutes.jsx b/frontend/components/LoginRoutes/LoginRoutes.jsx
index ad9d061148..7049a2490b 100644
--- a/frontend/components/LoginRoutes/LoginRoutes.jsx
+++ b/frontend/components/LoginRoutes/LoginRoutes.jsx
@@ -29,14 +29,14 @@ export class LoginRoutes extends Component {
render () {
const { containerStyles, logoStyles } = componentStyles;
- const { children } = this.props;
+ const { children, location: { pathname } } = this.props;
return (

-
+
{
+ const { location } = ownProps;
+
+ return { location };
+};
+
+export default connect(mapStateToProps)(LoginRoutes);
diff --git a/frontend/pages/HomePage/HomePage.jsx b/frontend/pages/HomePage/HomePage.jsx
index ac1eaa20b7..1fea78101d 100644
--- a/frontend/pages/HomePage/HomePage.jsx
+++ b/frontend/pages/HomePage/HomePage.jsx
@@ -17,7 +17,7 @@ export class HomePage extends Component {
return (
-
+ {user &&
}
You are successfully logged in!
{user &&
Logout}
diff --git a/frontend/pages/LoginPage/LoginPage.jsx b/frontend/pages/LoginPage/LoginPage.jsx
index 40cf4496df..622f3f25e5 100644
--- a/frontend/pages/LoginPage/LoginPage.jsx
+++ b/frontend/pages/LoginPage/LoginPage.jsx
@@ -5,7 +5,6 @@ import { push } from 'react-router-redux';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import { clearAuthErrors, loginUser } from '../../redux/nodes/auth/actions';
import debounce from '../../utilities/debounce';
-import local from '../../utilities/local';
import LoginForm from '../../components/forms/LoginForm';
import LoginSuccessfulPage from '../LoginSuccessfulPage';
import paths from '../../router/paths';
@@ -14,11 +13,11 @@ import './styles.scss';
const WHITELIST_ERRORS = ['Unable to authenticate the current user'];
export class LoginPage extends Component {
-
static propTypes = {
dispatch: PropTypes.func,
error: PropTypes.string,
loading: PropTypes.bool,
+ pathname: PropTypes.string,
user: PropTypes.object,
};
@@ -30,11 +29,10 @@ export class LoginPage extends Component {
}
componentWillMount () {
- const { dispatch } = this.props;
+ const { dispatch, pathname, user } = this.props;
+ const { HOME, LOGIN } = paths;
- if (local.getItem('auth_token')) {
- return dispatch(push('/'));
- }
+ if (user && pathname === LOGIN) return dispatch(push(HOME));
return false;
}
diff --git a/frontend/pages/LoginPage/LoginPage.tests.jsx b/frontend/pages/LoginPage/LoginPage.tests.jsx
index cb9216944c..eb8e1e1030 100644
--- a/frontend/pages/LoginPage/LoginPage.tests.jsx
+++ b/frontend/pages/LoginPage/LoginPage.tests.jsx
@@ -40,6 +40,7 @@ describe('LoginPage - component', () => {
it('redirects to the home page', () => {
const mockStore = reduxMockStore({ auth: { user } });
+ const props = { pathname: '/login' };
const redirectAction = {
type: '@@router/CALL_HISTORY_METHOD',
payload: {
@@ -48,7 +49,7 @@ describe('LoginPage - component', () => {
},
};
- mount(connectedComponent(LoginPage, { mockStore }));
+ mount(connectedComponent(LoginPage, { props, mockStore }));
expect(mockStore.getActions()).toInclude(redirectAction);
});
});
diff --git a/frontend/router/paths.js b/frontend/router/paths.js
index f49cbdae7b..93aecf47f3 100644
--- a/frontend/router/paths.js
+++ b/frontend/router/paths.js
@@ -4,5 +4,5 @@ export default {
HOME: '/',
LOGIN: '/login',
LOGOUT: '/logout',
- RESET_PASSWORD: '/reset_password',
+ RESET_PASSWORD: '/login/reset',
};