feat: add logout, updateProfile, updatePassword, deleteAccount to useAuth

This commit is contained in:
Ovidiu U
2026-04-11 13:05:04 +01:00
parent e90078d39e
commit 7976b9facc
3 changed files with 35 additions and 196 deletions

View File

@@ -40,5 +40,39 @@ export function useAuth() {
fetched.value = false
}
return { user, loading, isAuthenticated, userTier, isPaidTier, fetchUser, clearUser }
async function logout() {
try {
await api.post('/auth/logout')
} finally {
clearUser()
}
}
async function updateProfile(data) {
const response = await api.put('/user/profile', data)
user.value = response.data
}
async function updatePassword(data) {
await api.put('/user/password', data)
}
async function deleteAccount(password) {
await api.delete('/user', { data: { password } })
clearUser()
}
return {
user,
loading,
isAuthenticated,
userTier,
isPaidTier,
fetchUser,
clearUser,
logout,
updateProfile,
updatePassword,
deleteAccount,
}
}