use localeStorage to store isLoggedIn value

This commit is contained in:
axolotle 2023-07-28 17:30:56 +02:00
parent a7ddfca923
commit b82638f247

View file

@ -1,3 +1,17 @@
export const useIsLoggedIn = () => useState<boolean>('isLoggedIn', () => false)
export const useIsLoggedIn = () => {
const isLoggedIn = useState<boolean>(
'isLoggedIn',
() => localStorage.getItem('isLoggedIn') === 'true',
)
return computed({
get: () => isLoggedIn.value,
set: (value) => {
isLoggedIn.value = value
localStorage.setItem('isLoggedIn', value.toString())
},
})
}
export const useRedirectUrl = () =>
useState<string | null>('redirectUrl', () => null)