Add logout function and ADMIN_PASSWORD environment validation
This commit is contained in:
@@ -151,6 +151,17 @@ export default function AdminPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleLogout = () => {
|
||||
localStorage.removeItem('hoerdle_admin_auth');
|
||||
setIsAuthenticated(false);
|
||||
setPassword('');
|
||||
// Reset all state
|
||||
setSongs([]);
|
||||
setGenres([]);
|
||||
setSpecials([]);
|
||||
setDailyPuzzles([]);
|
||||
};
|
||||
|
||||
// Helper function to add auth headers to requests
|
||||
const getAuthHeaders = () => {
|
||||
const authToken = localStorage.getItem('hoerdle_admin_auth');
|
||||
@@ -779,7 +790,24 @@ export default function AdminPage() {
|
||||
|
||||
return (
|
||||
<div className="admin-container">
|
||||
<h1 className="title" style={{ marginBottom: '2rem' }}>Hördle Admin Dashboard</h1>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '2rem' }}>
|
||||
<h1 className="title" style={{ margin: 0 }}>Hördle Admin Dashboard</h1>
|
||||
<button
|
||||
onClick={handleLogout}
|
||||
className="btn-secondary"
|
||||
style={{
|
||||
padding: '0.5rem 1rem',
|
||||
backgroundColor: '#dc3545',
|
||||
color: 'white',
|
||||
border: 'none',
|
||||
borderRadius: '4px',
|
||||
cursor: 'pointer',
|
||||
fontSize: '0.9rem'
|
||||
}}
|
||||
>
|
||||
🚪 Logout
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Special Management */}
|
||||
<div className="admin-card" style={{ marginBottom: '2rem' }}>
|
||||
|
||||
Reference in New Issue
Block a user