feat: Introduce generic auth steps

This commit is contained in:
Ali BARIN
2021-10-14 18:34:30 +02:00
parent 1fbc58e7e1
commit 9c529b6c6d
12 changed files with 399 additions and 313 deletions

View File

@@ -0,0 +1,25 @@
import template from 'lodash.template';
const interpolate = /{([\s\S]+?)}/g;
type VARIABLES = {
[key: string]: any
}
const computeAuthStepVariables = (authStep: any, aggregatedData: any) => {
const variables: VARIABLES = {};
for (const field of authStep.fields) {
if (field.fields) {
variables[field.name] = computeAuthStepVariables(field, aggregatedData);
continue;
}
variables[field.name] = template(field.value, { interpolate })(aggregatedData);
}
return variables;
};
export default computeAuthStepVariables;