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

fix(console): auto close mfa switch (#6895)

This commit is contained in:
wangsijie 2024-12-20 11:47:57 +08:00 committed by GitHub
parent 7556c16849
commit d26d9aaa88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,5 @@
import { MfaFactor, MfaPolicy, type SignInExperience } from '@logto/schemas';
import { useContext, useMemo } from 'react';
import { useContext, useEffect, useMemo } from 'react';
import { Controller, useForm } from 'react-hook-form';
import { toast } from 'react-hot-toast';
import { useTranslation } from 'react-i18next';
@ -68,6 +68,13 @@ function MfaForm({ data, onMfaUpdated }: Props) {
return factors.length === 0;
}, [formValues, isMfaDisabled]);
useEffect(() => {
// Reset the `isMandatory` to false when the policy settings are disabled
if (isPolicySettingsDisabled) {
reset({ ...formValues, isMandatory: false });
}
}, [isPolicySettingsDisabled, reset, formValues]);
const mfaPolicyOptions = useMemo(
() => [
{