1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Add: Log in / Sign upの時にエラーが出たらAlertを表示する

Debug: Tray Icon, PopUpWindow, Menuがいつの間にか消える
This commit is contained in:
Rokt33r
2015-07-29 22:43:27 +09:00
parent 90c2ff7480
commit c6ef86cbbe
8 changed files with 194 additions and 34 deletions

View File

@@ -4,6 +4,8 @@ var Link = ReactRouter.Link
var AuthActions = require('../Actions/AuthActions')
var AuthStore = require('../Stores/AuthStore')
var OnlyGuest = require('../Mixins/OnlyGuest')
module.exports = React.createClass({
@@ -11,14 +13,50 @@ module.exports = React.createClass({
getInitialState: function () {
return {
email: '',
password: ''
password: '',
authenticationFailed: false,
connectionFailed: false,
isSending: false
}
},
componentDidMount: function () {
this.unsubscribe = AuthStore.listen(this.onListen)
},
componentWillUnmount: function () {
this.unsubscribe()
},
onListen: function (res) {
if (res.status === 'failedToLogIn') {
if (res.data.status === 401) {
// Wrong E-mail or Password
this.setState({
authenticationFailed: true,
connectionFailed: false,
isSending: false
})
return
}
// Connection Failed or Whatever
this.setState({
authenticationFailed: false,
connectionFailed: true,
isSending: false
})
return
}
},
handleSubmit: function (e) {
AuthActions.login({
email: this.state.email,
password: this.state.password
this.setState({
authenticationFailed: false,
connectionFailed: false,
isSending: true
}, function () {
AuthActions.login({
email: this.state.email,
password: this.state.password
})
})
e.preventDefault()
},
render: function () {
@@ -46,6 +84,19 @@ module.exports = React.createClass({
<div className='form-group'>
<input className='stripInput' valueLink={this.linkState('password')} onChange={this.handleChange} type='password' placeholder='Password'/>
</div>
{this.state.isSending ? (
<p className='alertInfo'>Logging in...</p>
) : null}
{this.state.connectionFailed ? (
<p className='alertError'>Please try again.</p>
) : null}
{this.state.authenticationFailed ? (
<p className='alertError'>Wrong E-mail or Password.</p>
) : null}
<div className='form-group'>
<button className='logInButton' type='submit'>Log In</button>
</div>