2 changed files with 0 additions and 73 deletions
@ -1,71 +0,0 @@ |
|||
"use client"; |
|||
|
|||
import { useEffect, useState } from "react"; |
|||
import { authBridge } from "@/lib/auth-bridge"; |
|||
|
|||
const TEST_SESSION_KEY = "TEST_DEBUG_NOT_LOGGED_IN"; |
|||
const TEST_SESSION_VALUE = "true"; |
|||
|
|||
function ensureTestSessionKey(isAuthenticated: boolean) { |
|||
if (typeof window === "undefined") { |
|||
return false; |
|||
} |
|||
|
|||
const existingValue = window.sessionStorage.getItem(TEST_SESSION_KEY); |
|||
|
|||
// Test-only behavior: create the key once for logged-out users and then
|
|||
// never overwrite or remove it, even after login.
|
|||
if (existingValue === null && !isAuthenticated) { |
|||
window.sessionStorage.setItem(TEST_SESSION_KEY, TEST_SESSION_VALUE); |
|||
return true; |
|||
} |
|||
|
|||
return existingValue !== null; |
|||
} |
|||
|
|||
function readOverlayState() { |
|||
if (typeof window === "undefined") { |
|||
return { |
|||
hasKey: false, |
|||
isAuthenticated: false, |
|||
}; |
|||
} |
|||
|
|||
const isAuthenticated = authBridge.isAuthenticated(); |
|||
|
|||
return { |
|||
hasKey: ensureTestSessionKey(isAuthenticated), |
|||
isAuthenticated, |
|||
}; |
|||
} |
|||
|
|||
export default function GlobalAuthDebugOverlay() { |
|||
const [overlayState, setOverlayState] = useState(readOverlayState); |
|||
|
|||
useEffect(() => { |
|||
const syncOverlayState = () => { |
|||
setOverlayState(readOverlayState()); |
|||
}; |
|||
|
|||
syncOverlayState(); |
|||
|
|||
window.addEventListener("focus", syncOverlayState); |
|||
const intervalId = window.setInterval(syncOverlayState, 1000); |
|||
|
|||
return () => { |
|||
window.removeEventListener("focus", syncOverlayState); |
|||
window.clearInterval(intervalId); |
|||
}; |
|||
}, []); |
|||
|
|||
return ( |
|||
<div className="pointer-events-none fixed inset-0 z-[9999] bg-black/50"> |
|||
<div className="absolute left-4 top-4 rounded-md bg-black/80 px-3 py-2 font-mono text-xs text-white"> |
|||
<div>auth: {overlayState.isAuthenticated ? "logged-in" : "logged-out"}</div> |
|||
<div> |
|||
{TEST_SESSION_KEY}: {overlayState.hasKey ? "exists" : "missing"} |
|||
</div> |
|||
</div> |
|||
</div> |
|||
); |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue