fix(auth): preserve phone login identity across step8 retries

This commit is contained in:
InkCrow
2026-05-12 16:41:09 +08:00
parent ff38933ce4
commit 1ed128e118
7 changed files with 127 additions and 19 deletions
+15 -7
View File
@@ -2993,14 +2993,22 @@ function isPhoneActivationForNumber(activation, phoneNumber) {
async function setEmailStateSilently(email, options = {}) {
const currentState = await getState();
const updates = buildRegistrationEmailStateUpdates(currentState, {
currentEmail: email,
preservePrevious: Boolean(options?.preservePrevious),
source: options?.source || '',
});
const preserveAccountIdentity = Boolean(options?.preserveAccountIdentity);
const updates = preserveAccountIdentity
? buildFlowRegistrationEmailStateUpdates(currentState, {
currentEmail: email,
preservePrevious: Boolean(options?.preservePrevious),
preserveAccountIdentity: true,
source: options?.source || '',
})
: buildRegistrationEmailStateUpdates(currentState, {
currentEmail: email,
preservePrevious: Boolean(options?.preservePrevious),
source: options?.source || '',
});
const normalizedEmail = updates.email;
if (normalizedEmail) {
if (!preserveAccountIdentity && normalizedEmail) {
updates.accountIdentifierType = 'email';
updates.accountIdentifier = normalizedEmail;
updates.phoneNumber = '';
@@ -3009,7 +3017,7 @@ async function setEmailStateSilently(email, options = {}) {
updates.signupPhoneCompletedActivation = null;
updates.signupPhoneVerificationRequestedAt = null;
updates.signupPhoneVerificationPurpose = '';
} else if (String(currentState?.accountIdentifierType || '').trim().toLowerCase() === 'email') {
} else if (!preserveAccountIdentity && String(currentState?.accountIdentifierType || '').trim().toLowerCase() === 'email') {
updates.accountIdentifierType = null;
updates.accountIdentifier = '';
}