Skip to content

Commit

Permalink
fix(idx): canRemediate nested object logic in GenericRemediator - OKT…
Browse files Browse the repository at this point in the history
  • Loading branch information
shuowu committed May 3, 2022
1 parent 73bc0e0 commit b76570d
Show file tree
Hide file tree
Showing 3 changed files with 310 additions and 53 deletions.
16 changes: 7 additions & 9 deletions lib/idx/remediators/GenericRemediator/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,19 @@ export function unwrapFormValue(remediation): Input {
export function hasValidInputValue(input, values) {
const fn = (input, values, requiredTracker) => {
const { name, value, required } = input;
const isRequired = required
|| requiredTracker
// TODO: confirm with backend why `required` meta is missing for authenticator remediation
|| name === 'authenticator';
if (!isRequired) {
return true;
}
const isRequired = required || requiredTracker;

if (Array.isArray(value)) {
return value.reduce((acc, item) => {
return acc && fn(item, values[name], isRequired);
}, true);
} else {
return !!(values && values[name]);
}

if (!isRequired) {
return true;
}

return !!(values && values[name]);
};

return fn(input, values, false);
Expand Down
3 changes: 3 additions & 0 deletions lib/idx/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export type Input = {
secret?: boolean;
required?: boolean;
options?: IdxOption[];
relatesTo?: IdxAuthenticator;
mutable?: boolean;
visible?: boolean;
}


Expand Down
Loading

0 comments on commit b76570d

Please sign in to comment.