Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
Merge cccb0f3 into 1eb5e84
Browse files Browse the repository at this point in the history
  • Loading branch information
mingyokim committed Jul 8, 2018
2 parents 1eb5e84 + cccb0f3 commit e7c0838
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions web/components/login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Login extends React.Component {
password: '',
loading: !isLoaded,
loggedIn: !isEmpty,
error: {},
};

this.onEmailChange = event => this.setState({ email: event.target.value });
Expand All @@ -33,44 +34,46 @@ class Login extends React.Component {
}

login(event) {
const { firebase, auth: { isLoaded, isEmpty } } = this.props;
const { firebase } = this.props;
const { email, password } = this.state;

event.preventDefault();
const credential = { email, password };
firebase.login(credential).then(() => {
this.setState({
loading: !isLoaded,
loggedIn: !isEmpty,
error: {},
});
}).catch((error) => {
console.log(error);
this.setState({ error });
});
}

loginView() {
const { email, password } = this.state;
const { email, password, error: { message } } = this.state;
return (
<form
onSubmit={this.login}
className="input-group">
<input
placeholder="Enter your email"
className="form-control"
value={email}
onChange={this.onEmailChange}
/>
<input
placeholder="Enter your password"
className="form-control"
value={password}
onChange={this.onPasswordChange}
/>
<span
className="input-group-btn">
<button type="submit" className="btn btn-secondary">Submit</button>
</span>
</form>
<div>
<form
onSubmit={this.login}
className="input-group">
<input
placeholder="Enter your email"
className="form-control"
value={email}
onChange={this.onEmailChange}
/>
<input
placeholder="Enter your password"
className="form-control"
value={password}
onChange={this.onPasswordChange}
/>
<span
className="input-group-btn">
<button type="submit" className="btn btn-secondary">Submit</button>
</span>
</form>
<p>{ message }</p>
</div>
);
}

Expand Down

0 comments on commit e7c0838

Please sign in to comment.