Fixed auth security
This commit is contained in:
@ -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>
|
||||
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
|
||||
document.getElementById("signout-btn")?.addEventListener("click", () => {
|
||||
clearAuthData();
|
||||
});
|
||||
|
||||
// Check visibility on load
|
||||
updateVisibility();
|
||||
|
||||
// Update visibility when auth state changes
|
||||
document.addEventListener("auth-success", updateVisibility);
|
||||
</script>
|
Reference in New Issue
Block a user