限制手机号注册流程使用号码复用
This commit is contained in:
@@ -519,6 +519,28 @@ test('updatePhoneVerificationSettingsUI toggles SMS rows from the sms switch and
|
||||
const api = new Function(`
|
||||
let phoneVerificationSectionExpanded = false;
|
||||
let latestState = {};
|
||||
let phoneSignupReuseUiWasLocked = false;
|
||||
const PHONE_SIGNUP_REUSE_LOCK_TITLE = '手机号注册流程不使用号码复用,切回邮箱注册后会恢复原设置';
|
||||
const SIGNUP_METHOD_EMAIL = 'email';
|
||||
const SIGNUP_METHOD_PHONE = 'phone';
|
||||
const DEFAULT_SIGNUP_METHOD = SIGNUP_METHOD_EMAIL;
|
||||
const DEFAULT_HERO_SMS_REUSE_ENABLED = true;
|
||||
function createMockClassList() {
|
||||
const values = new Set();
|
||||
return {
|
||||
toggle(name, force) {
|
||||
const enabled = force === undefined ? !values.has(name) : Boolean(force);
|
||||
if (enabled) values.add(name);
|
||||
else values.delete(name);
|
||||
},
|
||||
contains(name) {
|
||||
return values.has(name);
|
||||
},
|
||||
};
|
||||
}
|
||||
function createMockRow() {
|
||||
return { style: { display: 'none' }, classList: createMockClassList(), title: '' };
|
||||
}
|
||||
const inputPhoneVerificationEnabled = { checked: false };
|
||||
const rowPhoneVerificationEnabled = { style: { display: 'none' } };
|
||||
const rowPhoneVerificationFold = { style: { display: 'none' } };
|
||||
@@ -583,13 +605,24 @@ const rowHeroSmsCurrentNumber = { style: { display: 'none' } };
|
||||
const rowHeroSmsCurrentCountdown = { style: { display: 'none' } };
|
||||
const rowHeroSmsPriceTiers = { style: { display: 'none' } };
|
||||
const rowHeroSmsCurrentCode = { style: { display: 'none' } };
|
||||
const rowHeroSmsPreferredActivation = { style: { display: 'none' } };
|
||||
const rowHeroSmsPreferredActivation = createMockRow();
|
||||
const rowPhoneVerificationResendCount = { style: { display: 'none' } };
|
||||
const rowPhoneReplacementLimit = { style: { display: 'none' } };
|
||||
const rowPhoneCodeWaitSeconds = { style: { display: 'none' } };
|
||||
const rowPhoneCodeTimeoutWindows = { style: { display: 'none' } };
|
||||
const rowPhoneCodePollIntervalSeconds = { style: { display: 'none' } };
|
||||
const rowPhoneCodePollMaxRounds = { style: { display: 'none' } };
|
||||
const rowFreePhoneReuseEnabled = createMockRow();
|
||||
const rowFreePhoneReuseAutoEnabled = createMockRow();
|
||||
const rowFreeReusablePhone = createMockRow();
|
||||
const heroSmsReuseRow = createMockRow();
|
||||
const inputHeroSmsReuseEnabled = { checked: true, disabled: false, closest: () => heroSmsReuseRow };
|
||||
const inputFreePhoneReuseEnabled = { checked: true, disabled: false };
|
||||
const inputFreePhoneReuseAutoEnabled = { checked: true, disabled: false };
|
||||
const selectHeroSmsPreferredActivation = { disabled: false };
|
||||
const inputFreeReusablePhone = { disabled: false };
|
||||
const btnSaveFreeReusablePhone = { disabled: false };
|
||||
const btnClearFreeReusablePhone = { disabled: false };
|
||||
const PHONE_SMS_PROVIDER_HERO_SMS = 'hero-sms';
|
||||
const PHONE_SMS_PROVIDER_FIVE_SIM = '5sim';
|
||||
const PHONE_SMS_PROVIDER_NEXSMS = 'nexsms';
|
||||
@@ -602,10 +635,23 @@ function updateSignupMethodUI() {
|
||||
function syncSignupPhoneInputFromState() {
|
||||
rowSignupPhone.style.display = inputPhoneVerificationEnabled.checked && latestState.signupPhoneNumber ? '' : 'none';
|
||||
}
|
||||
function setFreePhoneReuseControlsLocked() {}
|
||||
function setFreePhoneReuseControlsLocked(locked) {
|
||||
inputFreePhoneReuseEnabled.disabled = Boolean(locked);
|
||||
inputFreePhoneReuseAutoEnabled.disabled = Boolean(locked)
|
||||
|| !Boolean(inputFreePhoneReuseEnabled.checked)
|
||||
|| !Boolean(inputPhoneVerificationEnabled.checked && phoneVerificationSectionExpanded);
|
||||
}
|
||||
function isAutoRunLockedPhase() { return false; }
|
||||
function isAutoRunScheduledPhase() { return false; }
|
||||
|
||||
${extractFunction('normalizeSignupMethod')}
|
||||
${extractFunction('normalizeHeroSmsReuseEnabledValue')}
|
||||
${extractFunction('isPhoneSignupReuseLocked')}
|
||||
${extractFunction('getStoredPhoneSmsReuseEnabled')}
|
||||
${extractFunction('getStoredFreePhoneReuseEnabled')}
|
||||
${extractFunction('getStoredFreePhoneReuseAutoEnabled')}
|
||||
${extractFunction('restorePhoneReuseControlsFromState')}
|
||||
${extractFunction('setElementReuseLockedState')}
|
||||
${extractFunction('updatePhoneVerificationSettingsUI')}
|
||||
|
||||
return {
|
||||
@@ -642,12 +688,23 @@ return {
|
||||
rowHeroSmsPriceTiers,
|
||||
rowHeroSmsCurrentCode,
|
||||
rowHeroSmsPreferredActivation,
|
||||
rowFreePhoneReuseEnabled,
|
||||
rowFreePhoneReuseAutoEnabled,
|
||||
rowFreeReusablePhone,
|
||||
rowPhoneVerificationResendCount,
|
||||
rowPhoneReplacementLimit,
|
||||
rowPhoneCodeWaitSeconds,
|
||||
rowPhoneCodeTimeoutWindows,
|
||||
rowPhoneCodePollIntervalSeconds,
|
||||
rowPhoneCodePollMaxRounds,
|
||||
heroSmsReuseRow,
|
||||
inputHeroSmsReuseEnabled,
|
||||
inputFreePhoneReuseEnabled,
|
||||
inputFreePhoneReuseAutoEnabled,
|
||||
selectHeroSmsPreferredActivation,
|
||||
inputFreeReusablePhone,
|
||||
btnSaveFreeReusablePhone,
|
||||
btnClearFreeReusablePhone,
|
||||
setSelectedPhoneSmsProvider(value) { selectPhoneSmsProvider.value = value; },
|
||||
updatePhoneVerificationSettingsUI,
|
||||
};
|
||||
@@ -733,6 +790,46 @@ return {
|
||||
assert.equal(api.rowPhoneCodePollIntervalSeconds.style.display, '');
|
||||
assert.equal(api.rowPhoneCodePollMaxRounds.style.display, '');
|
||||
|
||||
api.setLatestState({
|
||||
signupMethod: 'phone',
|
||||
signupPhoneNumber: '66959916439',
|
||||
phoneSmsReuseEnabled: true,
|
||||
freePhoneReuseEnabled: true,
|
||||
freePhoneReuseAutoEnabled: true,
|
||||
});
|
||||
api.updatePhoneVerificationSettingsUI();
|
||||
assert.equal(api.inputHeroSmsReuseEnabled.checked, false);
|
||||
assert.equal(api.inputHeroSmsReuseEnabled.disabled, true);
|
||||
assert.equal(api.inputFreePhoneReuseEnabled.checked, false);
|
||||
assert.equal(api.inputFreePhoneReuseEnabled.disabled, true);
|
||||
assert.equal(api.inputFreePhoneReuseAutoEnabled.checked, false);
|
||||
assert.equal(api.inputFreePhoneReuseAutoEnabled.disabled, true);
|
||||
assert.equal(api.selectHeroSmsPreferredActivation.disabled, true);
|
||||
assert.equal(api.inputFreeReusablePhone.disabled, true);
|
||||
assert.equal(api.btnSaveFreeReusablePhone.disabled, true);
|
||||
assert.equal(api.btnClearFreeReusablePhone.disabled, true);
|
||||
assert.equal(api.rowFreePhoneReuseEnabled.classList.contains('is-disabled'), true);
|
||||
assert.equal(api.rowFreeReusablePhone.classList.contains('is-disabled'), true);
|
||||
|
||||
api.setLatestState({
|
||||
signupMethod: 'email',
|
||||
signupPhoneNumber: '',
|
||||
phoneSmsReuseEnabled: true,
|
||||
freePhoneReuseEnabled: true,
|
||||
freePhoneReuseAutoEnabled: true,
|
||||
});
|
||||
api.updatePhoneVerificationSettingsUI();
|
||||
assert.equal(api.inputHeroSmsReuseEnabled.checked, true);
|
||||
assert.equal(api.inputHeroSmsReuseEnabled.disabled, false);
|
||||
assert.equal(api.inputFreePhoneReuseEnabled.checked, true);
|
||||
assert.equal(api.inputFreePhoneReuseEnabled.disabled, false);
|
||||
assert.equal(api.inputFreePhoneReuseAutoEnabled.checked, true);
|
||||
assert.equal(api.inputFreePhoneReuseAutoEnabled.disabled, false);
|
||||
assert.equal(api.selectHeroSmsPreferredActivation.disabled, false);
|
||||
assert.equal(api.inputFreeReusablePhone.disabled, false);
|
||||
assert.equal(api.btnSaveFreeReusablePhone.disabled, false);
|
||||
assert.equal(api.btnClearFreeReusablePhone.disabled, false);
|
||||
|
||||
api.setSelectedPhoneSmsProvider('5sim');
|
||||
api.updatePhoneVerificationSettingsUI();
|
||||
assert.equal(api.rowFiveSimApiKey.style.display, '');
|
||||
@@ -759,6 +856,19 @@ let latestState = {
|
||||
fiveSimCountryOrder: ['thailand', 'england'],
|
||||
heroSmsMinPrice: '0.0444',
|
||||
fiveSimMinPrice: '0.3333',
|
||||
phoneSmsReuseEnabled: false,
|
||||
heroSmsReuseEnabled: false,
|
||||
freePhoneReuseEnabled: false,
|
||||
freePhoneReuseAutoEnabled: false,
|
||||
phonePreferredActivation: {
|
||||
provider: 'hero-sms',
|
||||
activationId: 'stored-activation',
|
||||
phoneNumber: '66950001111',
|
||||
countryId: 52,
|
||||
countryLabel: 'Thailand',
|
||||
successfulUses: 2,
|
||||
maxUses: 3,
|
||||
},
|
||||
};
|
||||
let cloudflareDomainEditMode = false;
|
||||
let cloudflareTempEmailDomainEditMode = false;
|
||||
@@ -857,6 +967,9 @@ const PHONE_SMS_PROVIDER_HERO_SMS = 'hero-sms';
|
||||
const PHONE_SMS_PROVIDER_FIVE_SIM = '5sim';
|
||||
const PHONE_SMS_PROVIDER_NEXSMS = 'nexsms';
|
||||
const DEFAULT_PHONE_SMS_PROVIDER = PHONE_SMS_PROVIDER_HERO_SMS;
|
||||
const SIGNUP_METHOD_EMAIL = 'email';
|
||||
const SIGNUP_METHOD_PHONE = 'phone';
|
||||
const DEFAULT_SIGNUP_METHOD = SIGNUP_METHOD_EMAIL;
|
||||
const DEFAULT_FIVE_SIM_COUNTRY_ID = 'vietnam';
|
||||
const DEFAULT_FIVE_SIM_COUNTRY_LABEL = '越南 (Vietnam)';
|
||||
const DEFAULT_FIVE_SIM_OPERATOR = 'any';
|
||||
@@ -916,6 +1029,11 @@ ${extractFunction('normalizeHeroSmsAcquirePriority')}
|
||||
${extractFunction('normalizeHeroSmsCountryId')}
|
||||
${extractFunction('normalizeHeroSmsCountryLabel')}
|
||||
${extractFunction('getSelectedHeroSmsCountryOption')}
|
||||
${extractFunction('normalizeSignupMethod')}
|
||||
${extractFunction('isPhoneSignupReuseLocked')}
|
||||
${extractFunction('getStoredPhoneSmsReuseEnabled')}
|
||||
${extractFunction('getStoredFreePhoneReuseEnabled')}
|
||||
${extractFunction('getStoredFreePhoneReuseAutoEnabled')}
|
||||
function syncHeroSmsFallbackSelectionOrderFromSelect() {
|
||||
return [{ id: 52, label: 'Thailand' }, { id: 16, label: 'United Kingdom' }];
|
||||
}
|
||||
@@ -948,21 +1066,21 @@ return { collectSettingsPayload };
|
||||
assert.equal(payload.nexSmsApiKey, 'nex-key');
|
||||
assert.deepStrictEqual(payload.nexSmsCountryOrder, [1]);
|
||||
assert.equal(payload.nexSmsServiceCode, 'ot');
|
||||
assert.equal(payload.phoneSmsReuseEnabled, true);
|
||||
assert.equal(payload.heroSmsReuseEnabled, true);
|
||||
assert.equal(payload.freePhoneReuseEnabled, true);
|
||||
assert.equal(payload.freePhoneReuseAutoEnabled, true);
|
||||
assert.equal(payload.phoneSmsReuseEnabled, false);
|
||||
assert.equal(payload.heroSmsReuseEnabled, false);
|
||||
assert.equal(payload.freePhoneReuseEnabled, false);
|
||||
assert.equal(payload.freePhoneReuseAutoEnabled, false);
|
||||
assert.equal(payload.heroSmsAcquirePriority, 'price');
|
||||
assert.equal(payload.heroSmsMinPrice, '0.03');
|
||||
assert.equal(payload.heroSmsMaxPrice, '0.12');
|
||||
assert.equal(payload.heroSmsPreferredPrice, '0.0512');
|
||||
assert.deepStrictEqual(payload.phonePreferredActivation, {
|
||||
provider: 'hero-sms',
|
||||
activationId: 'demo-activation',
|
||||
phoneNumber: '66958889999',
|
||||
activationId: 'stored-activation',
|
||||
phoneNumber: '66950001111',
|
||||
countryId: 52,
|
||||
countryLabel: 'Thailand',
|
||||
successfulUses: 0,
|
||||
successfulUses: 2,
|
||||
maxUses: 3,
|
||||
});
|
||||
assert.equal(payload.phoneVerificationReplacementLimit, 5);
|
||||
|
||||
Reference in New Issue
Block a user