feat(dcauth): 新增后台手机号与设备认证登录
登录链路改为账号密码 + 短信验证码 + DCAuth 设备签名,并新增后台手机号绑定、 登录日志、设备绑定与重置接口。
This commit is contained in:
@@ -1,10 +1,44 @@
|
||||
import { apiGet, apiPost } from '@/lib/http'
|
||||
import type { AdminLoginResponse, AdminSessionSummary } from '@/types/admin'
|
||||
import type {
|
||||
AdminDevicePrepareResponse,
|
||||
AdminDeviceStatusResponse,
|
||||
AdminLoginResponse,
|
||||
AdminSessionSummary,
|
||||
AdminSmsCodeResponse,
|
||||
} from '@/types/admin'
|
||||
|
||||
export function loginAdmin(payload: { username: string; password: string }) {
|
||||
return apiPost<AdminLoginResponse>('/api/v1/admin/auth/login', payload)
|
||||
}
|
||||
|
||||
export function sendAdminLoginSmsCode(payload: { username: string; password: string }) {
|
||||
return apiPost<AdminSmsCodeResponse>('/api/v1/admin/auth/login/sms-code', payload)
|
||||
}
|
||||
|
||||
export function prepareAdminLogin(payload: {
|
||||
username: string
|
||||
password: string
|
||||
smsCode: string
|
||||
apiBase: string
|
||||
}) {
|
||||
return apiPost<AdminDevicePrepareResponse>('/api/v1/admin/auth/login/prepare', payload)
|
||||
}
|
||||
|
||||
export function fetchAdminDeviceStatus(challengeId: string, pollToken: string) {
|
||||
return apiGet<AdminDeviceStatusResponse>(
|
||||
`/api/dcauth/challenge/${encodeURIComponent(challengeId)}/status`,
|
||||
{ pollToken },
|
||||
)
|
||||
}
|
||||
|
||||
export function completeAdminLogin(payload: {
|
||||
challengeId: string
|
||||
pollToken: string
|
||||
deviceTicket: string
|
||||
}) {
|
||||
return apiPost<AdminLoginResponse>('/api/v1/admin/auth/login/complete', payload)
|
||||
}
|
||||
|
||||
export function fetchAdminSession() {
|
||||
return apiGet<AdminSessionSummary>('/api/v1/admin/auth/session')
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ export function createAdminUser(payload: {
|
||||
password: string
|
||||
role: string
|
||||
status?: string
|
||||
phone?: string
|
||||
testAccount?: boolean
|
||||
}) {
|
||||
return apiPost<{ user: AdminUserListItem }>('/api/v1/admin/users', payload)
|
||||
}
|
||||
@@ -64,3 +66,24 @@ export function resetAdminUserPassword(userId: number | string, payload: { passw
|
||||
payload,
|
||||
)
|
||||
}
|
||||
|
||||
export function updateAdminUserPhone(userId: number | string, payload: { phone: string }) {
|
||||
return apiPost<{ user: AdminUserListItem }>(`/api/v1/admin/users/${userId}/phone`, payload)
|
||||
}
|
||||
|
||||
export function resetAdminUserDevice(userId: number | string) {
|
||||
return apiPost<{ user: AdminUserListItem; reset: boolean }>(
|
||||
`/api/v1/admin/users/${userId}/device/reset`,
|
||||
{},
|
||||
)
|
||||
}
|
||||
|
||||
export function updateAdminUserTestAccount(
|
||||
userId: number | string,
|
||||
payload: { testAccount: boolean },
|
||||
) {
|
||||
return apiPost<{ user: AdminUserListItem; testAccount: boolean }>(
|
||||
`/api/v1/admin/users/${userId}/test-account`,
|
||||
payload,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user