TorbatYar/frontend/hooks/useHeaderSession.ts
Mortezakoohjani 800b0ba2c5 Deploy TorbatYar for torbatyar.ir with nginx multi-tenant routing.
Wire production domain, CORS for tenant subdomains, celery volume mounts, and nginx reverse proxy configs for apex, API, identity, auth, and wildcard tenants.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 21:43:33 +03:30

31 lines
774 B
TypeScript

"use client";
import { useEffect, useState } from "react";
import { usePathname } from "next/navigation";
import { getStoredToken } from "@/lib/auth";
/** تشخیص ورود SSO مرکزی. */
export function useHeaderSession() {
const pathname = usePathname();
const [isSsoAuth, setIsSsoAuth] = useState(false);
useEffect(() => {
const sync = () => {
setIsSsoAuth(!!getStoredToken());
};
sync();
window.addEventListener("focus", sync);
window.addEventListener("storage", sync);
return () => {
window.removeEventListener("focus", sync);
window.removeEventListener("storage", sync);
};
}, [pathname]);
return {
isAdminAuth: false,
isSsoAuth,
isLoggedIn: isSsoAuth,
};
}