Fix redirect to login when no auth

This commit is contained in:
Piotr Markiewicz 2024-04-26 13:40:31 +02:00
parent 434e49bf59
commit c387a6b0e8

View File

@ -1,7 +1,7 @@
import { useAuthStore } from "@/stores/auth"; import { useAuthStore } from "@/stores/auth";
import router from "@/router"; import router from "@/router";
import { JwtPayload, jwtDecode } from "jwt-decode"; import { JwtPayload, jwtDecode } from "jwt-decode";
import { baseURL } from "./constants"; import { baseURL, noAuth } from "./constants";
import { StatusError } from "@/api/utils"; import { StatusError } from "@/api/utils";
export function parseToken(token: string) { export function parseToken(token: string) {
@ -98,5 +98,9 @@ export function logout() {
authStore.clearUser(); authStore.clearUser();
localStorage.setItem("jwt", ""); localStorage.setItem("jwt", "");
router.push({ path: "/login" }); if (noAuth) {
window.location.reload();
} else {
router.push({path: "/login"});
}
} }