@@ -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({
diff --git a/client/modules/User/pages/SignupView.jsx b/client/modules/User/pages/SignupView.jsx
index 47278271..d5fbaedd 100644
--- a/client/modules/User/pages/SignupView.jsx
+++ b/client/modules/User/pages/SignupView.jsx
@@ -27,6 +27,10 @@ class SignupView extends React.Component {
}
render() {
+ if (this.props.user.authenticated) {
+ this.gotoHomePage();
+ return null;
+ }
return (
@@ -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({
diff --git a/server/routes/server.routes.js b/server/routes/server.routes.js
index 9993d792..87cbf3b4 100644
--- a/server/routes/server.routes.js
+++ b/server/routes/server.routes.js
@@ -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());
});