Skip to content

Instantly share code, notes, and snippets.

@sAbakumoff
Last active November 30, 2016 07:24
Show Gist options
  • Save sAbakumoff/cd8e9fb46571b3ce6d4b22bc883e1b91 to your computer and use it in GitHub Desktop.
Save sAbakumoff/cd8e9fb46571b3ce6d4b22bc883e1b91 to your computer and use it in GitHub Desktop.
export default class LoginContainer extends Component {
getInitState () {
return { username: '', password: ''};
}
onSubmit (event) {
event.preventDefault();
const {username, password} = this.state;
request
.post('/admin/login')
.send({username, password})
.end((error, res) => {
if (error) {
this.setState({
error: res.body.message
});
} else {
window.location.href = '/admin';
}
});
}
fieldChange (id, value) {
this.setState({[id]: value});
}
render () {
return (
<Login ref='login' {...this.props} {...this.state} onSubmit={::this.onSubmit} fieldChange={::this.fieldChange} />
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment