feat(auth): add admin bootstrap and username login

Initialize admin bootstrap settings during startup, persist username support in auth flows, and align frontend auth requests with local API behavior.
This commit is contained in:
2026-03-24 15:07:19 +08:00
parent 6f594631e9
commit a3aa15d339
13 changed files with 787 additions and 27 deletions

View File

@@ -3,7 +3,7 @@ import axios from 'axios'
let redirectingToLogin = false
const api = axios.create({
baseURL: import.meta.env.VITE_API_URL,
baseURL: import.meta.env.DEV ? '' : import.meta.env.VITE_API_URL,
timeout: 30000,
})

View File

@@ -6,16 +6,16 @@ let unauthorizedListenerRegistered = false
export const useAuthStore = defineStore('auth', () => {
const token = ref<string | null>(localStorage.getItem('access_token'))
const user = ref<{ id: string; email: string; full_name?: string } | null>(null)
const user = ref<{ id: string; username: string; email: string; full_name?: string } | null>(null)
const isAuthReady = ref(false)
const isFetchingUser = ref(false)
let authReadyPromise: Promise<void> | null = null
const isAuthenticated = computed(() => !!token.value)
async function login(email: string, password: string) {
async function login(identifier: string, password: string) {
const formData = new FormData()
formData.append('username', email)
formData.append('username', identifier)
formData.append('password', password)
const response = await api.post('/api/auth/login', formData, {
headers: { 'Content-Type': 'multipart/form-data' },