fix: clear signup phone mismatch runtime state
This commit is contained in:
+86
-75
@@ -7307,6 +7307,72 @@ function isSignupPhonePasswordMismatchFailure(error) {
|
||||
return /SIGNUP_PHONE_PASSWORD_MISMATCH::/i.test(message);
|
||||
}
|
||||
|
||||
function getSignupPhonePasswordMismatchRestartPayload(preservedState = {}) {
|
||||
const preservedEmail = String(preservedState.email || '').trim();
|
||||
const preservedPassword = String(preservedState.password || '').trim();
|
||||
const accountIdentifierType = String(preservedState.accountIdentifierType || '').trim().toLowerCase();
|
||||
const activeSignupPhoneNumber = String(
|
||||
preservedState.signupPhoneNumber
|
||||
|| preservedState.signupPhoneActivation?.phoneNumber
|
||||
|| preservedState.signupPhoneCompletedActivation?.phoneNumber
|
||||
|| (accountIdentifierType === 'phone' ? preservedState.accountIdentifier : '')
|
||||
|| ''
|
||||
).trim();
|
||||
const shouldClearSignupPhoneRuntime = Boolean(
|
||||
activeSignupPhoneNumber
|
||||
|| preservedState.signupPhoneActivation
|
||||
|| preservedState.signupPhoneCompletedActivation
|
||||
|| preservedState.signupPhoneVerificationRequestedAt
|
||||
|| preservedState.signupPhoneVerificationPurpose
|
||||
|| accountIdentifierType === 'phone'
|
||||
);
|
||||
const restorePayload = {};
|
||||
if (preservedEmail) restorePayload.email = preservedEmail;
|
||||
if (preservedPassword) restorePayload.password = preservedPassword;
|
||||
if (shouldClearSignupPhoneRuntime) {
|
||||
restorePayload.signupPhoneNumber = '';
|
||||
restorePayload.signupPhoneActivation = null;
|
||||
restorePayload.signupPhoneCompletedActivation = null;
|
||||
restorePayload.signupPhoneVerificationRequestedAt = null;
|
||||
restorePayload.signupPhoneVerificationPurpose = '';
|
||||
if (accountIdentifierType === 'phone') {
|
||||
restorePayload.accountIdentifierType = null;
|
||||
restorePayload.accountIdentifier = '';
|
||||
}
|
||||
}
|
||||
return {
|
||||
activeSignupPhoneNumber,
|
||||
preservedEmail,
|
||||
restorePayload,
|
||||
shouldClearSignupPhoneRuntime,
|
||||
};
|
||||
}
|
||||
|
||||
async function restartSignupPhonePasswordMismatchAttemptFromStep(step, restartCount, error) {
|
||||
const preservedState = await getState();
|
||||
const {
|
||||
activeSignupPhoneNumber,
|
||||
preservedEmail,
|
||||
restorePayload,
|
||||
shouldClearSignupPhoneRuntime,
|
||||
} = getSignupPhonePasswordMismatchRestartPayload(preservedState);
|
||||
const emailSuffix = preservedEmail ? `当前邮箱:${preservedEmail};` : '';
|
||||
const phoneSuffix = activeSignupPhoneNumber ? `当前手机号:${activeSignupPhoneNumber};` : '';
|
||||
await addLog(
|
||||
`步骤 ${step}:检测到手机号/密码不匹配,准备丢弃当前注册手机号并回到步骤 1 重新开始(第 ${restartCount} 次重开)。${phoneSuffix}${emailSuffix}原因:${getErrorMessage(error)}`,
|
||||
'warn'
|
||||
);
|
||||
await invalidateDownstreamAfterStepRestart(1, {
|
||||
logLabel: `步骤 ${step} 检测到手机号/密码不匹配后准备回到步骤 1 重新获取手机号重试(第 ${restartCount} 次重开)`,
|
||||
});
|
||||
if (shouldClearSignupPhoneRuntime) {
|
||||
await addLog(`步骤 ${step}:已清空本轮注册手机号与接码订单,下一次重开将重新获取号码。`, 'warn');
|
||||
}
|
||||
if (Object.keys(restorePayload).length) {
|
||||
await setState(restorePayload);
|
||||
}
|
||||
}
|
||||
|
||||
function isSignupUserAlreadyExistsFailure(error) {
|
||||
if (typeof loggingStatus !== 'undefined' && loggingStatus?.isSignupUserAlreadyExistsFailure) {
|
||||
return loggingStatus.isSignupUserAlreadyExistsFailure(error);
|
||||
@@ -9984,42 +10050,7 @@ async function runAutoSequenceFromStep(startStep, context = {}) {
|
||||
}
|
||||
if (isSignupPhonePasswordMismatchFailure(err)) {
|
||||
step4RestartCount += 1;
|
||||
const preservedState = await getState();
|
||||
const preservedEmail = String(preservedState.email || '').trim();
|
||||
const preservedPassword = String(preservedState.password || '').trim();
|
||||
const activeSignupPhoneNumber = String(
|
||||
preservedState.signupPhoneNumber
|
||||
|| preservedState.signupPhoneActivation?.phoneNumber
|
||||
|| preservedState.signupPhoneCompletedActivation?.phoneNumber
|
||||
|| ''
|
||||
).trim();
|
||||
const emailSuffix = preservedEmail ? `当前邮箱:${preservedEmail};` : '';
|
||||
const phoneSuffix = activeSignupPhoneNumber ? `当前手机号:${activeSignupPhoneNumber};` : '';
|
||||
await addLog(
|
||||
`步骤 3:检测到手机号/密码不匹配,准备丢弃当前注册手机号并回到步骤 1 重新开始(第 ${step4RestartCount} 次重开)。${phoneSuffix}${emailSuffix}原因:${getErrorMessage(err)}`,
|
||||
'warn'
|
||||
);
|
||||
await invalidateDownstreamAfterStepRestart(1, {
|
||||
logLabel: `步骤 3 检测到手机号/密码不匹配后准备回到步骤 1 重新获取手机号重试(第 ${step4RestartCount} 次重开)`,
|
||||
});
|
||||
const restorePayload = {};
|
||||
if (preservedEmail) restorePayload.email = preservedEmail;
|
||||
if (preservedPassword) restorePayload.password = preservedPassword;
|
||||
if (preservedState.signupPhoneActivation) {
|
||||
restorePayload.signupPhoneNumber = '';
|
||||
restorePayload.signupPhoneActivation = null;
|
||||
restorePayload.signupPhoneCompletedActivation = null;
|
||||
restorePayload.signupPhoneVerificationRequestedAt = null;
|
||||
restorePayload.signupPhoneVerificationPurpose = '';
|
||||
if (String(preservedState.accountIdentifierType || '').trim().toLowerCase() === 'phone') {
|
||||
restorePayload.accountIdentifierType = null;
|
||||
restorePayload.accountIdentifier = '';
|
||||
}
|
||||
await addLog('步骤 3:已清空本轮注册手机号与接码订单,下一次重开将重新获取号码。', 'warn');
|
||||
}
|
||||
if (Object.keys(restorePayload).length) {
|
||||
await setState(restorePayload);
|
||||
}
|
||||
await restartSignupPhonePasswordMismatchAttemptFromStep(3, step4RestartCount, err);
|
||||
currentStartStep = 1;
|
||||
continueCurrentAttempt = true;
|
||||
restartFromStep1WithCurrentEmail = true;
|
||||
@@ -10090,46 +10121,26 @@ async function runAutoSequenceFromStep(startStep, context = {}) {
|
||||
throw err;
|
||||
}
|
||||
step4RestartCount += 1;
|
||||
const preservedState = await getState();
|
||||
const preservedEmail = String(preservedState.email || '').trim();
|
||||
const preservedPassword = String(preservedState.password || '').trim();
|
||||
const isSignupPhonePasswordMismatch = /SIGNUP_PHONE_PASSWORD_MISMATCH::/i.test(getErrorMessage(err));
|
||||
const activeSignupPhoneNumber = String(
|
||||
preservedState.signupPhoneNumber
|
||||
|| preservedState.signupPhoneActivation?.phoneNumber
|
||||
|| preservedState.signupPhoneCompletedActivation?.phoneNumber
|
||||
|| ''
|
||||
).trim();
|
||||
const emailSuffix = preservedEmail ? `当前邮箱:${preservedEmail};` : '';
|
||||
const phoneSuffix = activeSignupPhoneNumber ? `当前手机号:${activeSignupPhoneNumber};` : '';
|
||||
await addLog(
|
||||
isSignupPhonePasswordMismatch
|
||||
? `步骤 4:检测到手机号/密码不匹配,准备丢弃当前注册手机号并回到步骤 1 重新开始(第 ${step4RestartCount} 次重开)。${phoneSuffix}${emailSuffix}原因:${getErrorMessage(err)}`
|
||||
: `步骤 4:执行失败,准备沿用当前邮箱回到步骤 1 重新开始(第 ${step4RestartCount} 次重开)。${emailSuffix}原因:${getErrorMessage(err)}`,
|
||||
'warn'
|
||||
);
|
||||
await invalidateDownstreamAfterStepRestart(1, {
|
||||
logLabel: isSignupPhonePasswordMismatch
|
||||
? `步骤 4 检测到手机号/密码不匹配后准备回到步骤 1 重新获取手机号重试(第 ${step4RestartCount} 次重开)`
|
||||
: `步骤 4 报错后准备回到步骤 1 沿用当前邮箱重试(第 ${step4RestartCount} 次重开)`,
|
||||
});
|
||||
const restorePayload = {};
|
||||
if (preservedEmail) restorePayload.email = preservedEmail;
|
||||
if (preservedPassword) restorePayload.password = preservedPassword;
|
||||
if (isSignupPhonePasswordMismatch && preservedState.signupPhoneActivation) {
|
||||
restorePayload.signupPhoneNumber = '';
|
||||
restorePayload.signupPhoneActivation = null;
|
||||
restorePayload.signupPhoneCompletedActivation = null;
|
||||
restorePayload.signupPhoneVerificationRequestedAt = null;
|
||||
restorePayload.signupPhoneVerificationPurpose = '';
|
||||
if (String(preservedState.accountIdentifierType || '').trim().toLowerCase() === 'phone') {
|
||||
restorePayload.accountIdentifierType = null;
|
||||
restorePayload.accountIdentifier = '';
|
||||
if (isSignupPhonePasswordMismatchFailure(err)) {
|
||||
await restartSignupPhonePasswordMismatchAttemptFromStep(4, step4RestartCount, err);
|
||||
} else {
|
||||
const preservedState = await getState();
|
||||
const preservedEmail = String(preservedState.email || '').trim();
|
||||
const preservedPassword = String(preservedState.password || '').trim();
|
||||
const emailSuffix = preservedEmail ? `当前邮箱:${preservedEmail};` : '';
|
||||
await addLog(
|
||||
`步骤 4:执行失败,准备沿用当前邮箱回到步骤 1 重新开始(第 ${step4RestartCount} 次重开)。${emailSuffix}原因:${getErrorMessage(err)}`,
|
||||
'warn'
|
||||
);
|
||||
await invalidateDownstreamAfterStepRestart(1, {
|
||||
logLabel: `步骤 4 报错后准备回到步骤 1 沿用当前邮箱重试(第 ${step4RestartCount} 次重开)`,
|
||||
});
|
||||
const restorePayload = {};
|
||||
if (preservedEmail) restorePayload.email = preservedEmail;
|
||||
if (preservedPassword) restorePayload.password = preservedPassword;
|
||||
if (Object.keys(restorePayload).length) {
|
||||
await setState(restorePayload);
|
||||
}
|
||||
await addLog('步骤 4:已清空本轮注册手机号与接码订单,下一次重开将重新获取号码。', 'warn');
|
||||
}
|
||||
if (Object.keys(restorePayload).length) {
|
||||
await setState(restorePayload);
|
||||
}
|
||||
currentStartStep = 1;
|
||||
continueCurrentAttempt = true;
|
||||
|
||||
Reference in New Issue
Block a user