Skip to content

Commit

Permalink
Fix redirect to login when no auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Markiewicz committed Apr 26, 2024
1 parent 434e49b commit c387a6b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions frontend/src/utils/auth.ts
@@ -1,7 +1,7 @@
import { useAuthStore } from "@/stores/auth";
import router from "@/router";
import { JwtPayload, jwtDecode } from "jwt-decode";
import { baseURL } from "./constants";
import { baseURL, noAuth } from "./constants";
import { StatusError } from "@/api/utils";

export function parseToken(token: string) {
Expand Down Expand Up @@ -98,5 +98,9 @@ export function logout() {
authStore.clearUser();

localStorage.setItem("jwt", "");
router.push({ path: "/login" });
if (noAuth) {
window.location.reload();
} else {
router.push({path: "/login"});

Check warning on line 104 in frontend/src/utils/auth.ts

View workflow job for this annotation

GitHub Actions / lint-frontend

Replace `path:路"/login"` with `路path:路"/login"路`
}
}

0 comments on commit c387a6b

Please sign in to comment.