限制手机号注册流程使用号码复用
This commit is contained in:
@@ -188,6 +188,42 @@
|
||||
verifyHotmailAccount,
|
||||
} = deps;
|
||||
|
||||
function preserveKeyFromState(updates, currentState, key) {
|
||||
if (!Object.prototype.hasOwnProperty.call(updates, key)) {
|
||||
return;
|
||||
}
|
||||
if (currentState?.[key] !== undefined) {
|
||||
updates[key] = currentState[key];
|
||||
} else {
|
||||
delete updates[key];
|
||||
}
|
||||
}
|
||||
|
||||
function preservePhoneReuseSettingsForPhoneSignup(updates, currentState = {}) {
|
||||
if (!updates || typeof updates !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
Object.prototype.hasOwnProperty.call(updates, 'phoneSmsReuseEnabled')
|
||||
|| Object.prototype.hasOwnProperty.call(updates, 'heroSmsReuseEnabled')
|
||||
) {
|
||||
const currentReuseEnabled = currentState?.phoneSmsReuseEnabled ?? currentState?.heroSmsReuseEnabled;
|
||||
if (currentReuseEnabled !== undefined) {
|
||||
const normalizedReuseEnabled = Boolean(currentReuseEnabled);
|
||||
updates.phoneSmsReuseEnabled = normalizedReuseEnabled;
|
||||
updates.heroSmsReuseEnabled = normalizedReuseEnabled;
|
||||
} else {
|
||||
delete updates.phoneSmsReuseEnabled;
|
||||
delete updates.heroSmsReuseEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
preserveKeyFromState(updates, currentState, 'freePhoneReuseEnabled');
|
||||
preserveKeyFromState(updates, currentState, 'freePhoneReuseAutoEnabled');
|
||||
preserveKeyFromState(updates, currentState, 'phonePreferredActivation');
|
||||
}
|
||||
|
||||
async function appendManualAccountRunRecordIfNeeded(status, stateOverride = null, reason = '') {
|
||||
if (typeof appendAccountRunRecord !== 'function') {
|
||||
return null;
|
||||
@@ -1248,6 +1284,12 @@
|
||||
) {
|
||||
updates.signupMethod = resolveSignupMethod(nextSignupState);
|
||||
}
|
||||
const nextPersistedSignupMethod = Object.prototype.hasOwnProperty.call(updates, 'signupMethod')
|
||||
? updates.signupMethod
|
||||
: currentState?.signupMethod;
|
||||
if (normalizeSignupMethod(nextPersistedSignupMethod) === 'phone') {
|
||||
preservePhoneReuseSettingsForPhoneSignup(updates, currentState);
|
||||
}
|
||||
const modeChanged = Object.prototype.hasOwnProperty.call(updates, 'plusModeEnabled')
|
||||
&& Boolean(currentState?.plusModeEnabled) !== Boolean(updates.plusModeEnabled);
|
||||
const plusPaymentChanged = Object.prototype.hasOwnProperty.call(updates, 'plusPaymentMethod')
|
||||
|
||||
@@ -923,6 +923,9 @@
|
||||
}
|
||||
|
||||
function isPhoneSmsReuseEnabled(state = {}) {
|
||||
if (isPhoneSignupIdentityState(state)) {
|
||||
return false;
|
||||
}
|
||||
return normalizePhoneSmsReuseEnabled(state);
|
||||
}
|
||||
|
||||
@@ -2112,6 +2115,18 @@
|
||||
};
|
||||
}
|
||||
|
||||
function isPhoneSignupIdentityState(state = {}) {
|
||||
const signupMethod = String(state?.resolvedSignupMethod || state?.signupMethod || '').trim().toLowerCase();
|
||||
const identifierType = String(state?.accountIdentifierType || '').trim().toLowerCase();
|
||||
if (signupMethod === 'phone' || identifierType === 'phone') {
|
||||
return true;
|
||||
}
|
||||
return Boolean(
|
||||
normalizeActivation(state?.signupPhoneActivation)
|
||||
|| normalizeActivation(state?.signupPhoneCompletedActivation)
|
||||
);
|
||||
}
|
||||
|
||||
function formatNoSupplySuggestion(context = {}) {
|
||||
const suggestions = [];
|
||||
const minPrice = Number(context?.minPrice);
|
||||
@@ -4677,6 +4692,9 @@
|
||||
}
|
||||
|
||||
async function handoffFreeReusablePhone(tabId, state = {}) {
|
||||
if (isPhoneSignupIdentityState(state)) {
|
||||
return null;
|
||||
}
|
||||
if (!normalizeFreePhoneReuseEnabled(state?.freePhoneReuseEnabled)) {
|
||||
return null;
|
||||
}
|
||||
@@ -4837,10 +4855,12 @@
|
||||
...state,
|
||||
phoneSmsProvider: normalizePhoneSmsProvider(providerName),
|
||||
});
|
||||
const canUseSavedActivationForCurrentFlow = !isPhoneSignupIdentityState(state);
|
||||
const preferredActivation = normalizeActivation(state[PREFERRED_PHONE_ACTIVATION_STATE_KEY]);
|
||||
let failedPreferredActivation = null;
|
||||
const canTryPreferredActivation = (
|
||||
!Boolean(options?.skipPreferredActivation)
|
||||
canUseSavedActivationForCurrentFlow
|
||||
&& !Boolean(options?.skipPreferredActivation)
|
||||
&& preferredActivation
|
||||
&& (provider === PHONE_SMS_PROVIDER_HERO || provider === PHONE_SMS_PROVIDER_5SIM)
|
||||
&& preferredActivation.provider === provider
|
||||
@@ -5021,6 +5041,9 @@
|
||||
|
||||
async function markActivationReusableAfterSuccess(state, activation) {
|
||||
const normalizedActivation = normalizeActivation(activation);
|
||||
if (isPhoneSignupIdentityState(state)) {
|
||||
return;
|
||||
}
|
||||
if (!isPhoneSmsReuseEnabled(state)) {
|
||||
await clearReusableActivation();
|
||||
return;
|
||||
@@ -5059,6 +5082,9 @@
|
||||
}
|
||||
|
||||
function shouldPreserveActivationForFreeReuse(state, activation) {
|
||||
if (isPhoneSignupIdentityState(state)) {
|
||||
return false;
|
||||
}
|
||||
if (!normalizeFreePhoneReuseEnabled(state?.freePhoneReuseEnabled)) {
|
||||
return false;
|
||||
}
|
||||
@@ -5072,6 +5098,9 @@
|
||||
}
|
||||
|
||||
function shouldSkipTerminalStatusForFreeReuse(state, activation) {
|
||||
if (isPhoneSignupIdentityState(state)) {
|
||||
return false;
|
||||
}
|
||||
const normalizedActivation = normalizeActivation(activation);
|
||||
if (!normalizedActivation || normalizedActivation.provider !== PHONE_SMS_PROVIDER_HERO) {
|
||||
return false;
|
||||
@@ -5102,6 +5131,9 @@
|
||||
...(state || {}),
|
||||
...(typeof getState === 'function' ? await getState() : {}),
|
||||
};
|
||||
if (isPhoneSignupIdentityState(latestState)) {
|
||||
return;
|
||||
}
|
||||
if (!normalizeFreePhoneReuseEnabled(latestState?.freePhoneReuseEnabled)) {
|
||||
return;
|
||||
}
|
||||
@@ -5141,6 +5173,9 @@
|
||||
...(state || {}),
|
||||
...(typeof getState === 'function' ? await getState() : {}),
|
||||
};
|
||||
if (isPhoneSignupIdentityState(latestState)) {
|
||||
return;
|
||||
}
|
||||
const savedActivation = normalizeFreeReusablePhoneActivation(
|
||||
latestState[FREE_REUSABLE_PHONE_ACTIVATION_STATE_KEY]
|
||||
);
|
||||
@@ -5185,6 +5220,9 @@
|
||||
...(state || {}),
|
||||
...(typeof getState === 'function' ? await getState() : {}),
|
||||
};
|
||||
if (isPhoneSignupIdentityState(latestState)) {
|
||||
return;
|
||||
}
|
||||
const savedActivation = normalizeFreeReusablePhoneActivation(
|
||||
latestState[FREE_REUSABLE_PHONE_ACTIVATION_STATE_KEY]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user