accounts-frontend/src/services/authFlow/PasswordState.js

37 lines
933 B
JavaScript
Raw Normal View History

2016-03-02 02:06:14 +05:30
import AbstractState from './AbstractState';
import CompleteState from './CompleteState';
import ForgotPasswordState from './ForgotPasswordState';
import LoginState from './LoginState';
2016-03-02 02:06:14 +05:30
export default class PasswordState extends AbstractState {
enter(context) {
const {auth} = context.getState();
2016-03-02 02:06:14 +05:30
if (auth.login) {
2016-03-02 02:06:14 +05:30
context.navigate('/password');
} else {
context.setState(new CompleteState());
2016-03-02 02:06:14 +05:30
}
}
resolve(context, {password, rememberMe}) {
const {auth: {login}} = context.getState();
2016-03-02 02:06:14 +05:30
context.run('login', {
password,
rememberMe,
login
2016-03-02 02:06:14 +05:30
})
.then(() => context.setState(new CompleteState()));
}
reject(context) {
context.setState(new ForgotPasswordState());
}
goBack(context) {
context.run('setLogin', null);
2016-03-02 02:06:14 +05:30
context.setState(new LoginState());
}
}