feat: Introduce generic auth steps
This commit is contained in:
25
packages/web/src/helpers/computeAuthStepVariables.ts
Normal file
25
packages/web/src/helpers/computeAuthStepVariables.ts
Normal 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;
|
Reference in New Issue
Block a user