2019-12-07 21:02:00 +02:00
|
|
|
import logger from 'app/services/logger';
|
2016-12-06 23:08:51 +02:00
|
|
|
|
2016-08-02 21:59:29 +03:00
|
|
|
import AbstractState from './AbstractState';
|
2020-01-17 23:37:52 +03:00
|
|
|
import { AuthContext } from './AuthFlow';
|
2016-08-02 21:59:29 +03:00
|
|
|
import CompleteState from './CompleteState';
|
|
|
|
|
|
|
|
export default class AcceptRulesState extends AbstractState {
|
2020-05-24 02:08:24 +03:00
|
|
|
enter(context: AuthContext): Promise<void> | void {
|
|
|
|
const { user } = context.getState();
|
2016-08-02 21:59:29 +03:00
|
|
|
|
2020-05-24 02:08:24 +03:00
|
|
|
if (user.shouldAcceptRules) {
|
|
|
|
context.navigate('/accept-rules');
|
|
|
|
} else {
|
|
|
|
context.setState(new CompleteState());
|
|
|
|
}
|
2016-08-02 21:59:29 +03:00
|
|
|
}
|
|
|
|
|
2020-05-24 02:08:24 +03:00
|
|
|
resolve(context: AuthContext): Promise<void> | void {
|
|
|
|
context
|
|
|
|
.run('acceptRules')
|
|
|
|
.then(() => context.setState(new CompleteState()))
|
|
|
|
.catch((err = {}) => err.errors || logger.warn('Error accepting rules', err));
|
|
|
|
}
|
2016-08-02 21:59:29 +03:00
|
|
|
|
2020-05-24 02:08:24 +03:00
|
|
|
reject(context: AuthContext): void {
|
|
|
|
context.run('logout');
|
|
|
|
}
|
2016-08-02 21:59:29 +03:00
|
|
|
}
|