From a4d724782d077607e20af91a246d9f0dfc7de05f Mon Sep 17 00:00:00 2001 From: Charles Zhao Date: Thu, 3 Apr 2025 12:48:11 +0800 Subject: [PATCH] fix(experience): browser password manager should pick up one-time token email from hidden input (#7232) fix(experience): browser password manager should pick up magic link email from hidden input --- packages/experience/src/pages/OneTimeToken/index.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/experience/src/pages/OneTimeToken/index.tsx b/packages/experience/src/pages/OneTimeToken/index.tsx index 4d71c2718..74cabb409 100644 --- a/packages/experience/src/pages/OneTimeToken/index.tsx +++ b/packages/experience/src/pages/OneTimeToken/index.tsx @@ -6,9 +6,10 @@ import { type RequestErrorBody, } from '@logto/schemas'; import { condString } from '@silverhand/essentials'; -import { useCallback, useEffect, useState } from 'react'; +import { useCallback, useContext, useEffect, useState } from 'react'; import { useSearchParams } from 'react-router-dom'; +import UserInteractionContext from '@/Providers/UserInteractionContextProvider/UserInteractionContext'; import { identifyAndSubmitInteraction, signInWithVerifiedIdentifier, @@ -31,6 +32,7 @@ const OneTimeToken = () => { const asyncSignInWithVerifiedIdentifier = useApi(signInWithVerifiedIdentifier); const asyncRegisterWithOneTimeToken = useApi(registerWithOneTimeToken); + const { setIdentifierInputValue } = useContext(UserInteractionContext); const { termsValidation, agreeToTermsPolicy } = useTerms(); const handleError = useErrorHandler(); const redirectTo = useGlobalRedirectTo(); @@ -129,6 +131,10 @@ const OneTimeToken = () => { return; } + // Set email identifier to the , so that when being asked for fulfilling + // the password later, the browser password manager can pick up both the email and the password. + setIdentifierInputValue({ type: SignInIdentifier.Email, value: email }); + await submit(result.verificationId); })(); }, [ @@ -136,8 +142,9 @@ const OneTimeToken = () => { params, asyncRegisterWithOneTimeToken, handleError, - termsValidation, + setIdentifierInputValue, submit, + termsValidation, ]); if (oneTimeTokenError) {