0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

fix(console): fix mfa form mandatory reset (#6901)

This commit is contained in:
wangsijie 2024-12-23 12:19:55 +08:00 committed by GitHub
parent 74c9282495
commit 6bb584a336
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -50,6 +50,7 @@ function MfaForm({ data, onMfaUpdated }: Props) {
handleSubmit,
control,
watch,
setValue,
} = useForm<MfaConfigForm>({ defaultValues: convertMfaConfigToForm(data), mode: 'onChange' });
const api = useApi();
@ -69,11 +70,12 @@ function MfaForm({ data, onMfaUpdated }: Props) {
}, [formValues, isMfaDisabled]);
useEffect(() => {
// Reset the `isMandatory` to false when the policy settings are disabled
if (isPolicySettingsDisabled) {
reset({ ...formValues, isMandatory: false });
// Reset the `isMandatory` to false when there is no MFA factor
const { factors } = convertMfaFormToConfig(formValues);
if (factors.length === 0 && formValues.isMandatory) {
setValue('isMandatory', false);
}
}, [isPolicySettingsDisabled, reset, formValues]);
}, [formValues, setValue]);
const mfaPolicyOptions = useMemo(
() => [