feat: add passkey authentication

This commit is contained in:
Zhixuan Jiang
2026-07-26 09:50:28 -04:00
parent 2730c1c43b
commit cc62979aa7
37 changed files with 1797 additions and 8 deletions
+1
View File
@@ -358,6 +358,7 @@ export const useAppStore = defineStore('app', () => {
github_oauth_enabled: false,
google_oauth_enabled: false,
backend_mode_enabled: false,
passkey_enabled: false,
version: siteVersion.value,
balance_low_notify_enabled: false,
account_quota_notify_enabled: false,
+13 -1
View File
@@ -5,7 +5,7 @@
import { defineStore } from 'pinia'
import { ref, computed, readonly } from 'vue'
import { authAPI, isTotp2FARequired, type LoginResponse } from '@/api'
import { authAPI, isTotp2FARequired, passkeyAPI, type LoginResponse } from '@/api'
import type { User, LoginRequest, RegisterRequest, AuthResponse } from '@/types'
const AUTH_TOKEN_KEY = 'auth_token'
@@ -275,6 +275,17 @@ export const useAuthStore = defineStore('auth', () => {
}
}
async function loginWithPasskey(): Promise<User> {
try {
const response = await passkeyAPI.login()
setAuthFromResponse(response)
return user.value!
} catch (error) {
clearAuth({ preservePendingAuthSession: pendingAuthSession.value !== null })
throw error
}
}
/**
* Set auth state from an AuthResponse
* Internal helper function
@@ -486,6 +497,7 @@ export const useAuthStore = defineStore('auth', () => {
// Actions
login,
loginWithPasskey,
login2FA,
register,
setToken,