Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/experience/src/hooks/use-mfa-error-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const useMfaErrorHandler = ({ replace }: Options = {}) => {
const startTotpBinding = useStartTotpBinding();
const startWebAuthnProcessing = useStartWebAuthnProcessing();
const startBackupCodeBinding = useStartBackupCodeBinding();
const { onSubmit: startMfaVerificationCodeProcessing } = useSendMfaVerificationCode();
const { onSubmit: startMfaVerificationCodeProcessing } = useSendMfaVerificationCode({ replace });

/**
* Redirect the user to the corresponding MFA page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import { type VerificationCodeIdentifier } from '@/types';
import { type MfaFlowState } from '@/types/guard';
import { codeVerificationTypeMap } from '@/utils/sign-in-experience';

const useSendMfaVerificationCode = () => {
type Options = {
/** Whether to replace the current page in the history stack on navigation. */
replace?: boolean;
};

const useSendMfaVerificationCode = ({ replace }: Options = {}) => {
const [errorMessage, setErrorMessage] = useState<string>();
const navigate = useNavigateWithPreservedSearchParams();

Expand Down Expand Up @@ -38,11 +43,11 @@ const useSendMfaVerificationCode = () => {

navigate(
`/mfa-verification/${identifier === 'email' ? MfaFactor.EmailVerificationCode : MfaFactor.PhoneVerificationCode}`,
{ state: flowState }
{ replace, state: flowState }
);
}
},
[asyncSendVerificationCode, handleError, navigate, setVerificationId]
[asyncSendVerificationCode, handleError, navigate, replace, setVerificationId]
);

return {
Expand Down
8 changes: 6 additions & 2 deletions packages/experience/src/pages/OneTimeToken/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ const OneTimeToken = () => {
const { termsValidation, agreeToTermsPolicy } = useTerms();
const handleError = useErrorHandler();
const redirectTo = useGlobalRedirectTo();
const preSignInErrorHandler = useSubmitInteractionErrorHandler(InteractionEvent.SignIn);
const preRegisterErrorHandler = useSubmitInteractionErrorHandler(InteractionEvent.Register);
const preSignInErrorHandler = useSubmitInteractionErrorHandler(InteractionEvent.SignIn, {
replace: true,
});
const preRegisterErrorHandler = useSubmitInteractionErrorHandler(InteractionEvent.Register, {
replace: true,
});

/**
* Update interaction event to `Register`, and then identify user and submit.
Expand Down
Loading