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
…A-495228

OKTA-495228
<<<Jenkins Check-In of Tested SHA: e9941d0 for [email protected]>>>
Artifact: okta-auth-js
Files changed count: 4
PR Link: #1200
  • Loading branch information
shuowu authored and eng-prod-CI-bot-okta committed May 3, 2022
1 parent 73bc0e0 commit f2f983c
Show file tree
Hide file tree
Showing 4 changed files with 320 additions and 53 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 6.5.1

### Fixes

- [#1200](https://github.com/okta/okta-auth-js/pull/1200) Fixes `canRemediate` logic in GenericRemediator (beta) to handle nested fields

### Other

- [#1200](https://github.com/okta/okta-auth-js/pull/1200) Adds missing fields to `Input` type in `idx` module

## 6.5.0

### Features
Expand Down
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 f2f983c

Please sign in to comment.