webadmin系统设置
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
* 门店登录 / 建店短信校验专项冒烟(需 API 已启动且 MOCK_SMS 开启)
|
||||
* 用法: node scripts/test-shop-auth.mjs
|
||||
*/
|
||||
import { resolveSmsCode, sendSmsWithCooldown } from './sms-test-helper.mjs';
|
||||
|
||||
const API = process.env.SMOKE_API ?? 'http://localhost:3000/api/v1';
|
||||
const MOCK_SMS_CODE = process.env.MOCK_SMS_CODE ?? '123456';
|
||||
|
||||
async function req(clientApp, path, options = {}) {
|
||||
const headers = {
|
||||
@@ -38,13 +39,11 @@ async function main() {
|
||||
if (!unbound.includes('未绑定门店')) throw new Error(`unexpected: ${unbound}`);
|
||||
|
||||
console.log('2. STORE_LOGIN bound phone');
|
||||
await req('SHOP_H5', '/shop/auth/sms/send', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ phone: '13910000001', scene: 'STORE_LOGIN' }),
|
||||
});
|
||||
await sendSmsWithCooldown('SHOP_H5', '/shop/auth/sms/send', '13910000001', 'STORE_LOGIN');
|
||||
const code = await resolveSmsCode('13910000001', 'STORE_LOGIN');
|
||||
const login = await req('SHOP_H5', '/shop/auth/login/sms', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ phone: '13910000001', code: MOCK_SMS_CODE }),
|
||||
body: JSON.stringify({ phone: '13910000001', code }),
|
||||
});
|
||||
if (!login.accessToken || !login.refreshToken) throw new Error('login missing tokens');
|
||||
|
||||
@@ -58,13 +57,11 @@ async function main() {
|
||||
if (!refreshed.accessToken) throw new Error('refresh failed');
|
||||
|
||||
console.log('4. Admin create store rejects occupied phone');
|
||||
await req('HQ_WEB', '/admin/auth/sms/send', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ phone: '13600000001', scene: 'HQ_LOGIN' }),
|
||||
});
|
||||
await sendSmsWithCooldown('HQ_WEB', '/admin/auth/sms/send', '13600000001', 'HQ_LOGIN');
|
||||
const adminCode = await resolveSmsCode('13600000001', 'HQ_LOGIN');
|
||||
const admin = await req('HQ_WEB', '/admin/auth/login/sms', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ phone: '13600000001', code: MOCK_SMS_CODE }),
|
||||
body: JSON.stringify({ phone: '13600000001', code: adminCode }),
|
||||
});
|
||||
const occupied = await expectFail('HQ_WEB', '/admin/stores', {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user