add frontend logout

This commit is contained in:
Yisroel Baum 2026-08-03 19:46:33 +03:00
parent d457c766c3
commit c15c13fd38
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
2 changed files with 58 additions and 0 deletions

View file

@ -101,6 +101,20 @@ export const useAuthStore = defineStore('auth', () => {
}
}
async function logout(): Promise<void> {
try {
await fetch(`${API_BASE}/api/logout`, {
method: 'POST',
credentials: 'include',
headers: {
Accept: 'application/json',
},
})
} finally {
user.value = null
}
}
return {
user,
loading,
@ -108,5 +122,6 @@ export const useAuthStore = defineStore('auth', () => {
isAuthenticated,
fetchMe,
login,
logout,
}
})