mirror of
https://github.com/logto-io/logto.git
synced 2025-01-13 21:30:30 -05:00
fix(console): fix mfa form mandatory reset (#6901)
This commit is contained in:
parent
74c9282495
commit
6bb584a336
1 changed files with 6 additions and 4 deletions
|
@ -50,6 +50,7 @@ function MfaForm({ data, onMfaUpdated }: Props) {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
control,
|
control,
|
||||||
watch,
|
watch,
|
||||||
|
setValue,
|
||||||
} = useForm<MfaConfigForm>({ defaultValues: convertMfaConfigToForm(data), mode: 'onChange' });
|
} = useForm<MfaConfigForm>({ defaultValues: convertMfaConfigToForm(data), mode: 'onChange' });
|
||||||
const api = useApi();
|
const api = useApi();
|
||||||
|
|
||||||
|
@ -69,11 +70,12 @@ function MfaForm({ data, onMfaUpdated }: Props) {
|
||||||
}, [formValues, isMfaDisabled]);
|
}, [formValues, isMfaDisabled]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Reset the `isMandatory` to false when the policy settings are disabled
|
// Reset the `isMandatory` to false when there is no MFA factor
|
||||||
if (isPolicySettingsDisabled) {
|
const { factors } = convertMfaFormToConfig(formValues);
|
||||||
reset({ ...formValues, isMandatory: false });
|
if (factors.length === 0 && formValues.isMandatory) {
|
||||||
|
setValue('isMandatory', false);
|
||||||
}
|
}
|
||||||
}, [isPolicySettingsDisabled, reset, formValues]);
|
}, [formValues, setValue]);
|
||||||
|
|
||||||
const mfaPolicyOptions = useMemo(
|
const mfaPolicyOptions = useMemo(
|
||||||
() => [
|
() => [
|
||||||
|
|
Loading…
Add table
Reference in a new issue