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

37 lines
1.0 KiB
JavaScript
Raw Normal View History

import logger from 'services/logger';
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()))
.catch((err = {}) => err.errors || logger.warn(err));
}
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());
}
}
}