shoc-frontend-new/src/lib/auth/expire-session.ts

13 lines
412 B
TypeScript
Raw Normal View History

import { clearAuth } from "@/lib/auth/auth-storage";
import queryClient from "@/lib/query/query-client";
import { stopQueryBroadcast } from "@/lib/query/setup-query-broadcast";
export function expireSessionAndRedirectToLogin(): void {
clearAuth();
stopQueryBroadcast(queryClient);
if (typeof window !== "undefined" && window.location.pathname !== "/login") {
window.location.replace("/login");
}
}