forked from mirrors/homebox
parent
0ef9d0deb8
commit
6e203e7833
2 changed files with 10 additions and 6 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue