Login and signup page not visible after login (#431)

* Login and signup page not visible after login

* Redirect added on server side
This commit is contained in:
Akarshit Wal 2017-09-30 00:22:20 +05:30 committed by Cassie Tarakajian
parent dad9284116
commit 20bc8633d7
3 changed files with 34 additions and 2 deletions

View file

@ -27,6 +27,10 @@ class LoginView extends React.Component {
} }
render() { render() {
if (this.props.user.authenticated) {
this.gotoHomePage();
return null;
}
return ( return (
<div className="form-container"> <div className="form-container">
<div className="form-container__header"> <div className="form-container__header">
@ -70,7 +74,16 @@ function mapDispatchToProps() {
} }
LoginView.propTypes = { LoginView.propTypes = {
previousPath: PropTypes.string.isRequired previousPath: PropTypes.string.isRequired,
user: {
authenticated: PropTypes.bool
}
};
LoginView.defaultProps = {
user: {
authenticated: false
}
}; };
export default reduxForm({ export default reduxForm({

View file

@ -27,6 +27,10 @@ class SignupView extends React.Component {
} }
render() { render() {
if (this.props.user.authenticated) {
this.gotoHomePage();
return null;
}
return ( return (
<div className="form-container"> <div className="form-container">
<div className="form-container__header"> <div className="form-container__header">
@ -84,7 +88,16 @@ function onSubmitFail(errors) {
} }
SignupView.propTypes = { SignupView.propTypes = {
previousPath: PropTypes.string.isRequired previousPath: PropTypes.string.isRequired,
user: {
authenticated: PropTypes.bool
}
};
SignupView.defaultProps = {
user: {
authenticated: false
}
}; };
export default reduxForm({ export default reduxForm({

View file

@ -14,6 +14,9 @@ router.route('/').get((req, res) => {
}); });
router.route('/signup').get((req, res) => { router.route('/signup').get((req, res) => {
if (req.user) {
return res.redirect('/');
}
res.send(renderIndex()); res.send(renderIndex());
}); });
@ -34,6 +37,9 @@ router.route('/:username/sketches/:project_id/*').get((req, res) => {
// }); // });
router.route('/login').get((req, res) => { router.route('/login').get((req, res) => {
if (req.user) {
return res.redirect('/');
}
res.send(renderIndex()); res.send(renderIndex());
}); });