Improve login and authentication methods to adapt to the SSR mode.

This commit is contained in:
Rafi
2023-04-03 22:04:52 +08:00
parent 5b9d52b177
commit 836df995d0
9 changed files with 24 additions and 25 deletions

View File

@@ -69,17 +69,16 @@ export const loadSettings = async () => {
}
export const fetchUser = async () => {
const { data, error } = await useFetch('/api/account/user/', {
// withCredentials: true
})
if (!error.value) {
setUser(data.value)
return null
}
return error
return useFetch('/api/account/user/')
}
export const setUser = (userData) => {
const user = useUser()
user.value = userData
}
export const logout = () => {
const user = useUser()
user.value = null
return navigateTo('/account/signin');
}