add passkey & totp

This commit is contained in:
biss committed 2026-08-27 21:45:39 +08:00
1 parent 70f6b52577
commit 1d06bbd482
13 files changed
+9114 -4

No files matched your search

+11 -1
View File
@@ -28,12 +28,21 @@ export const useAuthStore = defineStore('auth', () => {
const isLoggedIn = computed(() => Boolean(token.value))
const isSuperAdmin = computed(() => user.value?.roles.includes('SuperAdmin') ?? false)
async function login(userName: string, password: string) {
async function login(userName: string, password: string): Promise<{ twoFactorTicket?: string }> {
const { data } = await http.post('/auth/login', {
userName,
password,
isNativeApp: isNativeApp(),
})
if (data.requiresTotp) return { twoFactorTicket: String(data.twoFactorTicket) }
token.value = data.token
user.value = data.user
saveAuthSession(data)
return {}
}
async function completeTotpLogin(twoFactorTicket: string, code: string) {
const { data } = await http.post('/auth/login/totp', { twoFactorTicket, code })
token.value = data.token
user.value = data.user
saveAuthSession(data)
@@ -92,6 +101,7 @@ export const useAuthStore = defineStore('auth', () => {
isLoggedIn,
isSuperAdmin,
login,
completeTotpLogin,
exchangeSso,
bindSso,
refresh,