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

34 lines
934 B
JavaScript
Raw Normal View History

import AbstractState from './AbstractState';
import CompleteState from './CompleteState';
import ActivationState from './ActivationState';
2016-05-23 09:20:10 +05:30
import RegisterState from './RegisterState';
export default class ResendActivationState extends AbstractState {
enter(context) {
const {user} = context.getState();
if (user.isActive) {
context.setState(new CompleteState());
} else {
2016-05-23 09:20:10 +05:30
context.navigate('/resend-activation');
}
}
resolve(context, payload) {
context.run('resendActivation', payload)
.then(() => context.setState(new ActivationState()));
}
reject(context) {
context.setState(new ActivationState());
}
goBack(context) {
if (context.prevState instanceof RegisterState) {
2016-05-23 09:20:10 +05:30
context.setState(new RegisterState());
} else {
context.setState(new ActivationState());
}
}
}