feat: implement session restoration using /api/user/me

This commit is contained in:
2026-01-04 14:31:41 +03:00
parent 5c3df7a2a4
commit 4415e9508e

View File

@@ -92,11 +92,19 @@ export const useAuthStore = defineStore("auth", () => {
}
async function checkAuth() {
isLoading.value = true;
if (token.value) {
if (user.value) {
try {
apiClient.defaults.headers.common["Authorization"] = `Bearer ${token.value}`;
const response = await apiClient.get("/api/user/me");
user.value = response.data;
await fetchUserProfile();
} catch (e) {
console.error("Session restoration failed:", e);
handleLogout();
}
}
isLoading.value = false;
}
return {
// State