forked from mirrors/homebox
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;
|
|
}
|
|
});
|