diff --git a/src/stores/auth.ts b/src/stores/auth.ts index 0fed8dc..db5fe8f 100644 --- a/src/stores/auth.ts +++ b/src/stores/auth.ts @@ -13,12 +13,13 @@ export const useAuthStore = defineStore('auth', () => { async function login(username: string, password: string) { const response = await api.post('/auth/login', { username, password }) + // Set token BEFORE fetching user info (fetchUser needs the token for /auth/me) token.value = response.access_token localStorage.setItem('access_token', response.access_token) - + // Fetch user info await fetchUser() - + return response }