Skip to content

Commit

Permalink
fix(UserLoginForm): catch api.signin errors
Browse files Browse the repository at this point in the history
  • Loading branch information
HipsterBrown committed May 16, 2018
1 parent f04c71d commit baa1007
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/SignInForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,24 @@ class LoginForm extends React.Component {

signup() {
this.state.user.email = this.state.user.email && this.state.user.email.trim();

if (!isValidEmail(this.state.user.email)) {
return;
}

this.setState({ loading: true });
api.signin(this.state.user, this.props.next).then((result) => {

api.signin(this.state.user, this.props.next)
.then((result) => {
this.setState({ loginSent: true, signup: true, isNewUser: true, loading: false });

if (result.redirect) {
window.location.replace(result.redirect);
}
})
.catch((error) => {
this.error(error.message);
});
}

handleSubmit(e) {
Expand Down

0 comments on commit baa1007

Please sign in to comment.