修复手机号注册登录密码页与成功清理
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
getAutoRunStatusPayload,
|
||||
getErrorMessage,
|
||||
getFirstUnfinishedNodeId,
|
||||
getNodeIdsForState,
|
||||
getPendingAutoRunTimerPlan,
|
||||
getRunningNodeIds,
|
||||
getState,
|
||||
@@ -65,6 +66,77 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
const EMPTY_REGISTRATION_EMAIL_STATE = Object.freeze({
|
||||
current: '',
|
||||
previous: '',
|
||||
source: '',
|
||||
updatedAt: 0,
|
||||
});
|
||||
const DONE_NODE_STATUSES = new Set(['completed', 'manual_completed', 'skipped']);
|
||||
|
||||
function isPhoneSignupFlow(state = {}) {
|
||||
const resolvedSignupMethod = String(state?.resolvedSignupMethod || '').trim().toLowerCase();
|
||||
if (resolvedSignupMethod === 'phone' || resolvedSignupMethod === 'email') {
|
||||
return resolvedSignupMethod === 'phone';
|
||||
}
|
||||
const signupMethod = String(state?.signupMethod || '').trim().toLowerCase();
|
||||
return signupMethod === 'phone';
|
||||
}
|
||||
|
||||
function getFullWorkflowNodeIds(state = {}) {
|
||||
if (typeof getNodeIdsForState === 'function') {
|
||||
const nodeIds = getNodeIdsForState(state);
|
||||
if (Array.isArray(nodeIds) && nodeIds.length) {
|
||||
return Array.from(new Set(
|
||||
nodeIds
|
||||
.map((nodeId) => String(nodeId || '').trim())
|
||||
.filter(Boolean)
|
||||
));
|
||||
}
|
||||
}
|
||||
return getKnownNodeIdsFromState(state);
|
||||
}
|
||||
|
||||
function isFullWorkflowDone(state = {}) {
|
||||
const nodeIds = getFullWorkflowNodeIds(state);
|
||||
if (!nodeIds.length) {
|
||||
return false;
|
||||
}
|
||||
const nodeStatuses = state?.nodeStatuses || {};
|
||||
return nodeIds.every((nodeId) => DONE_NODE_STATUSES.has(String(nodeStatuses[nodeId] || 'pending').trim()));
|
||||
}
|
||||
|
||||
async function clearPhoneSignupRuntimeAfterRoundSuccess() {
|
||||
const currentState = await getState();
|
||||
if (!isPhoneSignupFlow(currentState) || !isFullWorkflowDone(currentState)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
await setState({
|
||||
accountIdentifierType: null,
|
||||
accountIdentifier: '',
|
||||
currentPhoneActivation: null,
|
||||
phoneNumber: '',
|
||||
signupPhoneNumber: '',
|
||||
signupPhoneActivation: null,
|
||||
signupPhoneCompletedActivation: null,
|
||||
signupPhoneVerificationRequestedAt: null,
|
||||
signupPhoneVerificationPurpose: '',
|
||||
currentPhoneVerificationCode: '',
|
||||
currentPhoneVerificationCountdownEndsAt: 0,
|
||||
currentPhoneVerificationCountdownWindowIndex: 0,
|
||||
currentPhoneVerificationCountdownWindowTotal: 0,
|
||||
email: null,
|
||||
registrationEmailState: { ...EMPTY_REGISTRATION_EMAIL_STATE },
|
||||
step8VerificationTargetEmail: '',
|
||||
lastEmailTimestamp: null,
|
||||
lastSignupCode: '',
|
||||
lastLoginCode: '',
|
||||
bindEmailSubmitted: false,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
async function waitForRunningWorkflowNodesToFinish(payload = {}) {
|
||||
if (typeof waitForRunningNodesToFinish === 'function') {
|
||||
return waitForRunningNodesToFinish(payload);
|
||||
@@ -698,6 +770,7 @@
|
||||
attemptRuns: attemptRun,
|
||||
continued: useExistingProgress,
|
||||
});
|
||||
await clearPhoneSignupRuntimeAfterRoundSuccess();
|
||||
|
||||
roundSummary.status = 'success';
|
||||
roundSummary.finalFailureReason = '';
|
||||
|
||||
Reference in New Issue
Block a user