2016-03-01 22:36:14 +02:00
|
|
|
import AbstractState from './AbstractState';
|
|
|
|
import LoginState from './LoginState';
|
2016-05-14 23:53:58 +03:00
|
|
|
import CompleteState from './CompleteState';
|
|
|
|
import RecoverPasswordState from './RecoverPasswordState';
|
2016-03-01 22:36:14 +02:00
|
|
|
|
|
|
|
export default class ForgotPasswordState extends AbstractState {
|
|
|
|
enter(context) {
|
2016-11-23 08:05:28 +02:00
|
|
|
if (this.getLogin(context)) {
|
|
|
|
context.navigate('/forgot-password');
|
2016-05-14 23:53:58 +03:00
|
|
|
} else {
|
|
|
|
context.setState(new CompleteState());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-27 13:34:44 +03:00
|
|
|
resolve(context, payload = {}) {
|
|
|
|
context.run('forgotPassword', {login: payload.email || this.getLogin(context)})
|
2016-05-14 23:53:58 +03:00
|
|
|
.then(() => context.setState(new RecoverPasswordState()));
|
2016-03-01 22:36:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
goBack(context) {
|
|
|
|
context.setState(new LoginState());
|
|
|
|
}
|
|
|
|
|
|
|
|
reject(context) {
|
2016-05-14 23:53:58 +03:00
|
|
|
context.setState(new RecoverPasswordState());
|
|
|
|
}
|
|
|
|
|
|
|
|
getLogin(context) {
|
2016-11-23 08:05:28 +02:00
|
|
|
const {auth} = context.getState();
|
2016-05-14 23:53:58 +03:00
|
|
|
|
2016-11-23 08:05:28 +02:00
|
|
|
return auth.login;
|
2016-03-01 22:36:14 +02:00
|
|
|
}
|
|
|
|
}
|