收紧店务端验证码登录准入

This commit is contained in:
2026-07-06 17:35:12 +08:00
parent 3c041e0895
commit 7d7d23a3d2
8 changed files with 124 additions and 6 deletions
@@ -2,6 +2,7 @@ const API_AUTH_FREE_PATHS = [
'/user/send-verification-code',
'/user/phone-login',
'/user/check/login-shops/phone/',
'/user/check/manager-login-shops/phone/',
'/legal-agreement/current'
]
+3
View File
@@ -50,6 +50,9 @@ export const authApi = {
getPhoneLoginShops(phone: string): Promise<LoginShopSelectionResponse> {
return api.get(`/user/check/login-shops/phone/${encodeURIComponent(phone)}`)
},
getManagerPhoneLoginShops(phone: string): Promise<LoginShopSelectionResponse> {
return api.get(`/user/check/manager-login-shops/phone/${encodeURIComponent(phone)}`)
},
getCurrentAgreements(): Promise<LegalAgreement[]> {
return api.get('/legal-agreement/current')
},
+12 -3
View File
@@ -9,8 +9,8 @@
<section class="card auth-card">
<div class="mode-tabs">
<button type="button" :class="{ active: loginMode === 'password' }" @click="switchMode('password')">密码登录</button>
<button type="button" :class="{ active: loginMode === 'phone' }" @click="switchMode('phone')">验证码登录</button>
<button type="button" :class="{ active: loginMode === 'password' }" @click="switchMode('password')">密码登录</button>
</div>
<div v-if="loginMode === 'password'" class="field">
@@ -117,7 +117,7 @@ const session = useSessionStore()
const toast = useToastStore()
const appIconUrl = `${import.meta.env.BASE_URL}assets/images/app-icon.png`
const preference = readJson<LoginPreference>(LOGIN_PREFERENCE_KEY, {})
const loginMode = ref<LoginMode>(preference.loginMode || 'password')
const loginMode = ref<LoginMode>(preference.loginMode || 'phone')
const form = reactive({
account: preference.account || '',
password: '',
@@ -213,6 +213,12 @@ const sendLoginCode = async (): Promise<void> => {
}
codeLoading.value = true
try {
const selection = await authApi.getManagerPhoneLoginShops(form.phone)
const shops = Array.isArray(selection.shops) ? selection.shops : []
if (!selection.allowShoplessLogin && shops.length === 0) {
toast.error(selection.message || '仅店长或美甲师可登录店务端')
return
}
await authApi.sendLoginCode(form.phone)
toast.success('验证码已发送')
startCountdown()
@@ -259,8 +265,11 @@ const showLoginError = (error: unknown): void => {
const openShopSelector = async (): Promise<boolean> => {
const selection = loginMode.value === 'password'
? await authApi.getPasswordLoginShops(form.account)
: await authApi.getPhoneLoginShops(form.phone)
: await authApi.getManagerPhoneLoginShops(form.phone)
const shops = Array.isArray(selection.shops) ? selection.shops : []
if (!selection.allowShoplessLogin && shops.length === 0) {
throw new Error(selection.message || '仅店长或美甲师可登录店务端')
}
if (shops.length <= 1) {
return false
}