Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
feat: add log statements + remove auto redirect (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
hay-kot authored Dec 16, 2023
1 parent 85c8e47 commit 3ee150e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
3 changes: 0 additions & 3 deletions frontend/composables/use-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ export function useUserApi(): UserClient {
if (r.status === 401) {
console.error("unauthorized request, invalidating session");
authCtx.invalidateSession();
if (window.location.pathname !== "/") {
window.location.href = "/";
}
}
});

Expand Down
1 change: 1 addition & 0 deletions frontend/composables/use-auth-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class AuthContext implements IAuthContext {
}

isAuthorized() {
console.debug("isAuthorized", this.token);
return this.token;
}

Expand Down
2 changes: 2 additions & 0 deletions frontend/middleware/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default defineNuxtRouteMiddleware(async () => {

if (!ctx.isAuthorized()) {
if (window.location.pathname !== "/") {
console.debug("[middleware/auth] isAuthorized returned false, redirecting to /");
return navigateTo("/");
}
}
Expand All @@ -13,6 +14,7 @@ export default defineNuxtRouteMiddleware(async () => {
const { data, error } = await api.user.self();
if (error) {
if (window.location.pathname !== "/") {
console.debug("[middleware/user] user is null and fetch failed, redirecting to /");
return navigateTo("/");
}
}
Expand Down

0 comments on commit 3ee150e

Please sign in to comment.