2016-12-10 21:28:47 +05:30
|
|
|
import logger from 'services/logger';
|
|
|
|
|
2016-03-02 02:06:14 +05:30
|
|
|
import AbstractState from './AbstractState';
|
|
|
|
import CompleteState from './CompleteState';
|
|
|
|
import ForgotPasswordState from './ForgotPasswordState';
|
2016-03-02 02:22:59 +05:30
|
|
|
import LoginState from './LoginState';
|
2016-03-02 02:06:14 +05:30
|
|
|
|
|
|
|
export default class PasswordState extends AbstractState {
|
|
|
|
enter(context) {
|
2016-11-13 02:01:44 +05:30
|
|
|
const {auth} = context.getState();
|
2016-03-02 02:06:14 +05:30
|
|
|
|
2016-11-13 02:01:44 +05:30
|
|
|
if (auth.login) {
|
2016-03-02 02:06:14 +05:30
|
|
|
context.navigate('/password');
|
2016-05-15 02:23:58 +05:30
|
|
|
} else {
|
|
|
|
context.setState(new CompleteState());
|
2016-03-02 02:06:14 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-04 19:16:39 +05:30
|
|
|
resolve(context, {password, rememberMe}) {
|
2016-11-13 02:01:44 +05:30
|
|
|
const {auth: {login}} = context.getState();
|
2016-03-02 02:06:14 +05:30
|
|
|
|
2017-01-29 17:42:08 +05:30
|
|
|
return context.run('login', {
|
2016-03-02 02:06:14 +05:30
|
|
|
password,
|
2016-06-04 19:16:39 +05:30
|
|
|
rememberMe,
|
2016-11-13 02:01:44 +05:30
|
|
|
login
|
2016-03-02 02:06:14 +05:30
|
|
|
})
|
2017-01-31 11:35:36 +05:30
|
|
|
.then(() => context.setState(new CompleteState()))
|
2016-12-10 21:28:47 +05:30
|
|
|
.catch((err = {}) => err.errors || logger.warn(err));
|
2016-03-02 02:06:14 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
reject(context) {
|
|
|
|
context.setState(new ForgotPasswordState());
|
|
|
|
}
|
|
|
|
|
|
|
|
goBack(context) {
|
2016-11-13 02:01:44 +05:30
|
|
|
context.run('setLogin', null);
|
2016-03-02 02:06:14 +05:30
|
|
|
context.setState(new LoginState());
|
|
|
|
}
|
|
|
|
}
|