diff --git a/src/public/js/actions/users.js b/src/public/js/actions/users.js index 61e9552..a06de7c 100644 --- a/src/public/js/actions/users.js +++ b/src/public/js/actions/users.js @@ -34,7 +34,9 @@ export function updateUser(config) { export function userSignUp(config) { return request( "USER_SIGNUP", - configureAxios().post("/users/signup", config) + configureAxios().post("/users/signup", config), [ + () => loginUser(config.username, config.password), + ], ) } diff --git a/src/public/js/components/users/signup.js b/src/public/js/components/users/signup.js index 80ec06b..d76d960 100644 --- a/src/public/js/components/users/signup.js +++ b/src/public/js/components/users/signup.js @@ -4,6 +4,12 @@ import { bindActionCreators } from "redux" import { userSignUp } from "../../actions/users" +function mapStateToProps(state) { + return { + isLogged: state.userStore.get("isLogged"), + }; +} + const mapDispatchToProps = (dispatch) => bindActionCreators({ userSignUp }, dispatch) @@ -20,6 +26,13 @@ class UserSignUp extends React.PureComponent { "password_confirm": this.refs.passwordConfirm.value, }); } + componentWillReceiveProps(nextProps) { + if (!nextProps.isLogged) { + return + } + // Redirect home + nextProps.router.push("/"); + } render() { return (