Skip to content

Commit

Permalink
fix(console): auto close mfa switch (#6895)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangsijie authored Dec 20, 2024
1 parent 7556c16 commit d26d9aa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/console/src/pages/Mfa/MfaForm/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(
() => [
{
Expand Down

0 comments on commit d26d9aa

Please sign in to comment.