Last active
November 30, 2016 07:24
-
-
Save sAbakumoff/cd8e9fb46571b3ce6d4b22bc883e1b91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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