accounts-frontend/packages/app/services/authFlow/RegisterState.ts

28 lines
765 B
TypeScript
Raw Normal View History

import logger from 'app/services/logger';
2016-03-02 02:06:14 +05:30
import AbstractState from './AbstractState';
import CompleteState from './CompleteState';
import ActivationState from './ActivationState';
2016-05-23 09:20:10 +05:30
import ResendActivationState from './ResendActivationState';
2016-03-02 02:06:14 +05:30
export default class RegisterState extends AbstractState {
enter(context) {
context.navigate('/register');
}
2016-03-02 02:06:14 +05:30
resolve(context, payload) {
context
.run('register', payload)
.then(() => context.setState(new CompleteState()))
.catch((err = {}) => err.errors || logger.warn('Error registering', err));
}
2016-03-02 02:06:14 +05:30
reject(context, payload) {
if (payload.requestEmail) {
context.setState(new ResendActivationState());
} else {
context.setState(new ActivationState());
2016-03-02 02:06:14 +05:30
}
}
2016-03-02 02:06:14 +05:30
}