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

36 lines
911 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 {user} = context.getState();
if (user.isGuest) {
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}) {
const {user} = context.getState();
context.run('login', {
password,
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());
}
}