fix(auth): preserve phone login identity across step8 retries
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
reuseOrCreateTab,
|
||||
sendToContentScriptResilient,
|
||||
buildRegistrationEmailStateUpdates = null,
|
||||
persistRegistrationEmailState = null,
|
||||
phoneVerificationHelpers = null,
|
||||
setState,
|
||||
shouldUseCustomRegistrationEmail,
|
||||
@@ -181,10 +182,17 @@
|
||||
}
|
||||
|
||||
const displayedEmail = normalizeStep8VerificationTargetEmail(result?.displayedEmail || resolvedEmail);
|
||||
await setState({
|
||||
email: resolvedEmail,
|
||||
step8VerificationTargetEmail: displayedEmail,
|
||||
});
|
||||
if (typeof persistRegistrationEmailState === 'function') {
|
||||
await persistRegistrationEmailState(latestState, resolvedEmail, {
|
||||
source: 'step8_add_email',
|
||||
preserveAccountIdentity: true,
|
||||
});
|
||||
} else {
|
||||
await setState({
|
||||
email: resolvedEmail,
|
||||
step8VerificationTargetEmail: displayedEmail,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
state: {
|
||||
@@ -535,6 +543,8 @@
|
||||
}
|
||||
},
|
||||
targetEmail: fixedTargetEmail,
|
||||
maxResendRequests: mail.provider === '2925' ? 1 : undefined,
|
||||
initialPollMaxAttempts: mail.provider === '2925' ? 5 : undefined,
|
||||
resendIntervalMs: mail.provider === LUCKMAIL_PROVIDER
|
||||
? 15000
|
||||
: ((mail.provider === HOTMAIL_PROVIDER || mail.provider === '2925')
|
||||
|
||||
@@ -71,9 +71,7 @@
|
||||
}
|
||||
|
||||
function shouldPreferStep7PhoneSignupIdentity(state = {}) {
|
||||
const frozenSignupMethod = normalizeStep7IdentifierType(state?.resolvedSignupMethod);
|
||||
return canUseConfiguredPhoneSignup(state)
|
||||
&& frozenSignupMethod !== 'email'
|
||||
&& hasStep7PhoneSignupIdentity(state);
|
||||
}
|
||||
|
||||
|
||||
@@ -874,6 +874,7 @@
|
||||
onResendRequestedAt,
|
||||
maxRounds: _ignoredMaxRounds,
|
||||
maxResendRequests: _ignoredMaxResendRequests,
|
||||
initialPollMaxAttempts: _ignoredInitialPollMaxAttempts,
|
||||
...cleanPollOverrides
|
||||
} = pollOverrides;
|
||||
const basePayload = {
|
||||
@@ -927,6 +928,7 @@
|
||||
onResendRequestedAt,
|
||||
maxRounds: _ignoredMaxRounds,
|
||||
maxResendRequests: _ignoredMaxResendRequests,
|
||||
initialPollMaxAttempts: _ignoredInitialPollMaxAttempts,
|
||||
...cleanPollOverrides
|
||||
} = pollOverrides;
|
||||
|
||||
@@ -982,6 +984,7 @@
|
||||
let filterAfterTimestamp = cleanPollOverrides.filterAfterTimestamp ?? getVerificationPollPayload(step, state).filterAfterTimestamp;
|
||||
const maxResendRequests = resolveMaxResendRequests(pollOverrides);
|
||||
const maxRounds = maxResendRequests + 1;
|
||||
const initialPollMaxAttempts = Math.max(0, Math.floor(Number(pollOverrides.initialPollMaxAttempts) || 0));
|
||||
let usedResendRequests = 0;
|
||||
|
||||
for (let round = 1; round <= maxRounds; round++) {
|
||||
@@ -1002,6 +1005,9 @@
|
||||
filterAfterTimestamp,
|
||||
excludeCodes: [...rejectedCodes],
|
||||
});
|
||||
if (round === 1 && initialPollMaxAttempts > 0) {
|
||||
payload.maxAttempts = initialPollMaxAttempts;
|
||||
}
|
||||
|
||||
try {
|
||||
const timedPoll = await applyMailPollingTimeBudget(
|
||||
@@ -1307,6 +1313,7 @@
|
||||
disableTimeBudgetCap: Boolean(options.disableTimeBudgetCap),
|
||||
getRemainingTimeMs: options.getRemainingTimeMs,
|
||||
maxResendRequests: remainingAutomaticResendCount,
|
||||
initialPollMaxAttempts: options.initialPollMaxAttempts,
|
||||
resendIntervalMs,
|
||||
lastResendAt,
|
||||
onResendRequestedAt: updateFilterAfterTimestampForVerificationStep,
|
||||
|
||||
Reference in New Issue
Block a user