mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-26 15:00:23 +05:30
be08857edc
Handle more errors for device code. Dispatch a BSOD for an any unhandled exception from auth flow state
30 lines
872 B
TypeScript
30 lines
872 B
TypeScript
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 {
|
|
return context.run('acceptRules').then(() => context.setState(new CompleteState()));
|
|
}
|
|
|
|
reject(context: AuthContext, payload: Record<string, any>): void {
|
|
if (payload.deleteAccount) {
|
|
context.navigate('/profile/delete');
|
|
|
|
return;
|
|
}
|
|
|
|
context.run('logout');
|
|
}
|
|
}
|