Fixed auth security

This commit is contained in:
2025-02-25 10:21:46 -06:00
parent 1e5222edd9
commit 103037de96

View File

@ -1,10 +1,28 @@
<button id="signout-btn" class="btn btn-secondary">Sign Out</button> {/* Initially hidden */}
<button id="signout-btn" class="btn btn-secondary hidden">Sign Out</button>
<script> <script>
import { clearAuthData } from "../utils/auth-client"; import { clearAuthData, isAuthenticated } from "../utils/auth-client";
function updateVisibility() {
const button = document.getElementById("signout-btn");
if (button) {
if (isAuthenticated()) {
button.classList.remove("hidden");
} else {
button.classList.add("hidden");
}
}
}
// Add click handler to the button // Add click handler to the button
document.getElementById("signout-btn")?.addEventListener("click", () => { document.getElementById("signout-btn")?.addEventListener("click", () => {
clearAuthData(); clearAuthData();
}); });
// Check visibility on load
updateVisibility();
// Update visibility when auth state changes
document.addEventListener("auth-success", updateVisibility);
</script> </script>