0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-04-07 23:01:25 -05:00

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
This commit is contained in:
Charles Zhao 2025-04-03 12:48:11 +08:00 committed by GitHub
parent c71f25d83e
commit a4d724782d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 <HiddenIdentifierInput />, 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) {