mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-24 06:28:34 +01:00
@@ -3,14 +3,18 @@ export default defineNuxtRouteMiddleware(async () => {
|
||||
const api = useUserApi();
|
||||
|
||||
if (!ctx.isAuthorized()) {
|
||||
return navigateTo("/");
|
||||
if (window.location.pathname !== "/") {
|
||||
return navigateTo("/");
|
||||
}
|
||||
}
|
||||
|
||||
if (!ctx.user) {
|
||||
console.log("Fetching user data");
|
||||
const { data, error } = await api.user.self();
|
||||
if (error) {
|
||||
return navigateTo("/");
|
||||
if (window.location.pathname !== "/") {
|
||||
return navigateTo("/");
|
||||
}
|
||||
}
|
||||
|
||||
ctx.user = data.item;
|
||||
|
||||
Reference in New Issue
Block a user