Fixed auth security

This commit is contained in:
2025-02-25 09:59:25 -06:00
parent 0be45ac39b
commit 4d2353b2c3
24 changed files with 681 additions and 350 deletions

View File

@ -1,30 +1,24 @@
import React, { useEffect, useState } from "react";
import { clearAuthData, isAuthenticated } from "../utils/auth-client";
const SignOut = () => {
const [isVisible, setIsVisible] = useState(false);
useEffect(() => {
const isAuthenticated = sessionStorage.getItem("isAuthenticated") === "true";
setIsVisible(isAuthenticated);
setIsVisible(isAuthenticated());
const handleAuthChange = () => {
setIsVisible(sessionStorage.getItem("isAuthenticated") === "true");
setIsVisible(isAuthenticated());
};
document.addEventListener("auth-success", handleAuthChange);
return () => document.removeEventListener("auth-success", handleAuthChange);
}, []);
const handleSignOut = () => {
sessionStorage.removeItem("isAuthenticated");
sessionStorage.removeItem("role");
window.location.reload();
};
if (!isVisible) return null;
return (
<button onClick={handleSignOut} className="btn btn-secondary">
<button onClick={clearAuthData} className="btn btn-secondary">
Sign Out
</button>
);