accounts-frontend/packages/app/services/authFlow/InitOAuthAuthCodeFlowState.ts

25 lines
983 B
TypeScript
Raw Normal View History

2016-03-02 02:06:14 +05:30
import AbstractState from './AbstractState';
import { AuthContext } from './AuthFlow';
2016-03-02 02:06:14 +05:30
import CompleteState from './CompleteState';
export default class InitOAuthAuthCodeFlowState extends AbstractState {
2020-05-24 04:38:24 +05:30
enter(context: AuthContext): Promise<void> | void {
const { query, params } = context.getRequest();
2016-03-02 02:06:14 +05:30
2020-05-24 04:38:24 +05:30
return context
.run('oAuthValidate', {
params: {
clientId: query.get('client_id') || params.clientId,
redirectUrl: query.get('redirect_uri')!,
responseType: query.get('response_type')!,
scope: (query.get('scope') || '').replace(/,/g, ' '),
state: query.get('state')!,
},
description: query.get('description')!,
prompt: query.get('prompt')!,
loginHint: query.get('login_hint')!,
2020-05-24 04:38:24 +05:30
})
.then(() => context.setState(new CompleteState()));
}
2016-03-02 02:06:14 +05:30
}