mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-27 23:40:28 +05:30
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import logger from 'app/services/logger';
|
|
|
|
import AbstractState from './AbstractState';
|
|
import { AuthContext } from './AuthFlow';
|
|
import CompleteState from './CompleteState';
|
|
|
|
export default class AcceptRulesState extends AbstractState {
|
|
enter(context: AuthContext): Promise<void> | void {
|
|
const { user } = context.getState();
|
|
|
|
if (!user.isDeleted && user.shouldAcceptRules) {
|
|
context.navigate('/accept-rules');
|
|
} else {
|
|
context.setState(new CompleteState());
|
|
}
|
|
}
|
|
|
|
resolve(context: AuthContext): Promise<void> | void {
|
|
context
|
|
.run('acceptRules')
|
|
.then(() => context.setState(new CompleteState()))
|
|
.catch((err = {}) => err.errors || logger.warn('Error accepting rules', err));
|
|
}
|
|
|
|
reject(context: AuthContext, payload: Record<string, any>): void {
|
|
if (payload.deleteAccount) {
|
|
context.navigate('/profile/delete');
|
|
|
|
return;
|
|
}
|
|
|
|
context.run('logout');
|
|
}
|
|
}
|