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:
parent
dad9284116
commit
20bc8633d7
3 changed files with 34 additions and 2 deletions
|
@ -27,6 +27,10 @@ class LoginView extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
if (this.props.user.authenticated) {
|
||||
this.gotoHomePage();
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<div className="form-container">
|
||||
<div className="form-container__header">
|
||||
|
@ -70,7 +74,16 @@ function mapDispatchToProps() {
|
|||
}
|
||||
|
||||
LoginView.propTypes = {
|
||||
previousPath: PropTypes.string.isRequired
|
||||
previousPath: PropTypes.string.isRequired,
|
||||
user: {
|
||||
authenticated: PropTypes.bool
|
||||
}
|
||||
};
|
||||
|
||||
LoginView.defaultProps = {
|
||||
user: {
|
||||
authenticated: false
|
||||
}
|
||||
};
|
||||
|
||||
export default reduxForm({
|
||||
|
|
|
@ -27,6 +27,10 @@ class SignupView extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
if (this.props.user.authenticated) {
|
||||
this.gotoHomePage();
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<div className="form-container">
|
||||
<div className="form-container__header">
|
||||
|
@ -84,7 +88,16 @@ function onSubmitFail(errors) {
|
|||
}
|
||||
|
||||
SignupView.propTypes = {
|
||||
previousPath: PropTypes.string.isRequired
|
||||
previousPath: PropTypes.string.isRequired,
|
||||
user: {
|
||||
authenticated: PropTypes.bool
|
||||
}
|
||||
};
|
||||
|
||||
SignupView.defaultProps = {
|
||||
user: {
|
||||
authenticated: false
|
||||
}
|
||||
};
|
||||
|
||||
export default reduxForm({
|
||||
|
|
|
@ -14,6 +14,9 @@ router.route('/').get((req, res) => {
|
|||
});
|
||||
|
||||
router.route('/signup').get((req, res) => {
|
||||
if (req.user) {
|
||||
return res.redirect('/');
|
||||
}
|
||||
res.send(renderIndex());
|
||||
});
|
||||
|
||||
|
@ -34,6 +37,9 @@ router.route('/:username/sketches/:project_id/*').get((req, res) => {
|
|||
// });
|
||||
|
||||
router.route('/login').get((req, res) => {
|
||||
if (req.user) {
|
||||
return res.redirect('/');
|
||||
}
|
||||
res.send(renderIndex());
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue