refactor: iterate array, not generator in auth steps
This commit is contained in:
@@ -21,14 +21,6 @@ type Response = {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
function* authStepGenerator(steps: any[]) {
|
|
||||||
for (const step of steps) {
|
|
||||||
yield step;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function AddAppConnection(props: AddAppConnectionProps){
|
export default function AddAppConnection(props: AddAppConnectionProps){
|
||||||
const { application, onClose } = props;
|
const { application, onClose } = props;
|
||||||
const { key, fields, authenticationSteps } = application;
|
const { key, fields, authenticationSteps } = application;
|
||||||
@@ -46,16 +38,16 @@ export default function AddAppConnection(props: AddAppConnectionProps){
|
|||||||
fields: data,
|
fields: data,
|
||||||
};
|
};
|
||||||
|
|
||||||
const stepGenerator = authStepGenerator(authenticationSteps);
|
let stepIndex = 0;
|
||||||
|
while (stepIndex < authenticationSteps.length) {
|
||||||
let authenticationStep;
|
const step = authenticationSteps[stepIndex];
|
||||||
while (!(authenticationStep = stepGenerator.next()).done) {
|
|
||||||
const step = authenticationStep.value;
|
|
||||||
const variables = computeAuthStepVariables(step, response);
|
const variables = computeAuthStepVariables(step, response);
|
||||||
|
|
||||||
const stepResponse = await processStep(step, variables);
|
const stepResponse = await processStep(step, variables);
|
||||||
|
|
||||||
response[step.name] = stepResponse;
|
response[step.name] = stepResponse;
|
||||||
|
|
||||||
|
stepIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
onClose?.();
|
onClose?.();
|
||||||
|
Reference in New Issue
Block a user