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

36 lines
961 B
JavaScript
Raw Normal View History

// @flow
2018-05-03 10:45:09 +05:30
import type { AuthContext } from 'services/authFlow';
import logger from 'services/logger';
import AbstractState from './AbstractState';
import ActivationState from './ActivationState';
2016-05-23 09:20:10 +05:30
import RegisterState from './RegisterState';
export default class ResendActivationState extends AbstractState {
enter(context: AuthContext) {
context.navigate('/resend-activation');
}
resolve(context: AuthContext, payload: Object) {
context
.run('resendActivation', payload)
.then(() => context.setState(new ActivationState()))
.catch(
(err = {}) =>
err.errors || logger.warn('Error resending activation', err),
);
}
reject(context: AuthContext) {
context.setState(new ActivationState());
}
goBack(context: AuthContext) {
if (context.prevState instanceof RegisterState) {
context.setState(new RegisterState());
} else {
context.setState(new ActivationState());
}
}
}