mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-22 23:06:31 +00:00
12975ce26e
* frontend cookie implementation * accept cookies for authentication * remove auth store * add self attr
13 lines
267 B
TypeScript
13 lines
267 B
TypeScript
export default defineNuxtRouteMiddleware(async () => {
|
|
const ctx = useAuthContext();
|
|
const api = useUserApi();
|
|
|
|
if (!ctx.user) {
|
|
const { data, error } = await api.user.self();
|
|
if (error) {
|
|
navigateTo("/");
|
|
}
|
|
|
|
ctx.user = data.item;
|
|
}
|
|
});
|