mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-27 23:40:28 +05:30
be08857edc
Handle more errors for device code. Dispatch a BSOD for an any unhandled exception from auth flow state
29 lines
898 B
TypeScript
29 lines
898 B
TypeScript
import AbstractState from './AbstractState';
|
|
import { AuthContext } from './AuthFlow';
|
|
import CompleteState from './CompleteState';
|
|
import DeviceCodeState from './DeviceCodeState';
|
|
|
|
export default class InitOAuthDeviceCodeFlowState extends AbstractState {
|
|
async enter(context: AuthContext): Promise<void> {
|
|
const { query } = context.getRequest();
|
|
|
|
const userCode = query.get('user_code');
|
|
|
|
if (userCode) {
|
|
try {
|
|
await context.run('oAuthValidate', {
|
|
params: { userCode },
|
|
description: query.get('description')!,
|
|
prompt: query.get('prompt')!,
|
|
});
|
|
|
|
return context.setState(new CompleteState());
|
|
} catch {
|
|
// Ok, fallback to the default
|
|
}
|
|
}
|
|
|
|
return context.setState(new DeviceCodeState());
|
|
}
|
|
}
|