2024-12-11 01:12:06 +05:30
|
|
|
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')!,
|
|
|
|
});
|
2024-12-18 03:41:39 +05:30
|
|
|
|
|
|
|
return context.setState(new CompleteState());
|
2024-12-11 01:12:06 +05:30
|
|
|
} catch {
|
|
|
|
// Ok, fallback to the default
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return context.setState(new DeviceCodeState());
|
|
|
|
}
|
|
|
|
}
|