mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-22 00:25:43 +00:00
feat: add log statements + remove auto redirect (#671)
Former-commit-id: 3ee150e7d6
This commit is contained in:
parent
1cc9bf459a
commit
d759fad40c
3 changed files with 3 additions and 3 deletions
|
@ -36,9 +36,6 @@ export function useUserApi(): UserClient {
|
||||||
if (r.status === 401) {
|
if (r.status === 401) {
|
||||||
console.error("unauthorized request, invalidating session");
|
console.error("unauthorized request, invalidating session");
|
||||||
authCtx.invalidateSession();
|
authCtx.invalidateSession();
|
||||||
if (window.location.pathname !== "/") {
|
|
||||||
window.location.href = "/";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ class AuthContext implements IAuthContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
isAuthorized() {
|
isAuthorized() {
|
||||||
|
console.debug("isAuthorized", this.token);
|
||||||
return this.token;
|
return this.token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ export default defineNuxtRouteMiddleware(async () => {
|
||||||
|
|
||||||
if (!ctx.isAuthorized()) {
|
if (!ctx.isAuthorized()) {
|
||||||
if (window.location.pathname !== "/") {
|
if (window.location.pathname !== "/") {
|
||||||
|
console.debug("[middleware/auth] isAuthorized returned false, redirecting to /");
|
||||||
return navigateTo("/");
|
return navigateTo("/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +14,7 @@ export default defineNuxtRouteMiddleware(async () => {
|
||||||
const { data, error } = await api.user.self();
|
const { data, error } = await api.user.self();
|
||||||
if (error) {
|
if (error) {
|
||||||
if (window.location.pathname !== "/") {
|
if (window.location.pathname !== "/") {
|
||||||
|
console.debug("[middleware/user] user is null and fetch failed, redirecting to /");
|
||||||
return navigateTo("/");
|
return navigateTo("/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue