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) {
|
|
|
|
const {user} = context.getState();
|
|
|
|
|
2016-05-15 02:23:58 +05:30
|
|
|
if (user.isGuest) {
|
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-03-02 02:06:14 +05:30
|
|
|
const {user} = context.getState();
|
|
|
|
|
|
|
|
context.run('login', {
|
|
|
|
password,
|
2016-06-04 19:16:39 +05:30
|
|
|
rememberMe,
|
2016-03-02 02:06:14 +05:30
|
|
|
login: user.email || user.username
|
|
|
|
})
|
|
|
|
.then(() => context.setState(new CompleteState()));
|
|
|
|
}
|
|
|
|
|
|
|
|
reject(context) {
|
|
|
|
context.setState(new ForgotPasswordState());
|
|
|
|
}
|
|
|
|
|
|
|
|
goBack(context) {
|
|
|
|
context.run('logout');
|
|
|
|
context.setState(new LoginState());
|
|
|
|
}
|
|
|
|
}
|