Files
SongRequest/SongRequest/templates/login.html
cottongin ea40251e0e Add web dashboard auth system and session management actions
Implement per-admin authentication with IRC-managed accounts
(addSongAdmin/removeSongAdmin/listSongAdmins), session-based login,
and admin presence tracking via WebSocket. Legacy webAuthToken
retained as fallback.

Add rename, clear, and delete actions for archived sessions with
themed modal confirmations (admin-only UI).

Made-with: Cursor
2026-03-28 12:02:42 -04:00

242 lines
6.1 KiB
HTML

<!DOCTYPE html>
<html lang="en" data-theme="system">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Login - Song Requests</title>
<style>
:root {
--bg: #0f0f0f;
--surface: #1a1a1a;
--surface-hover: #242424;
--border: #2a2a2a;
--text: #e8e8e8;
--text-muted: #888;
--accent: #fa2d48;
--accent-hover: #ff4562;
--approve: #2dd4a0;
--radius: 12px;
}
[data-theme="light"] {
--bg: #f5f5f7;
--surface: #ffffff;
--surface-hover: #f0f0f0;
--border: #e0e0e0;
--text: #1d1d1f;
--text-muted: #6e6e73;
}
@media (prefers-color-scheme: light) {
[data-theme="system"] {
--bg: #f5f5f7;
--surface: #ffffff;
--surface-hover: #f0f0f0;
--border: #e0e0e0;
--text: #1d1d1f;
--text-muted: #6e6e73;
}
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: system-ui, -apple-system, sans-serif;
font-size: 16px;
background: var(--bg);
color: var(--text);
line-height: 1.5;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.login-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 2rem;
width: 100%;
max-width: 380px;
margin: 1rem;
}
.login-header {
text-align: center;
margin-bottom: 1.5rem;
}
.login-logo {
width: 48px;
height: 48px;
background: linear-gradient(135deg, var(--accent), #fc6076);
border-radius: 12px;
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 1.5rem;
margin-bottom: 0.75rem;
}
.login-header h1 {
font-size: 1.25rem;
font-weight: 600;
letter-spacing: -0.02em;
}
.login-header p {
color: var(--text-muted);
font-size: 0.875rem;
margin-top: 0.25rem;
}
.field {
margin-bottom: 1rem;
}
.field label {
display: block;
font-size: 0.8125rem;
font-weight: 500;
color: var(--text-muted);
margin-bottom: 0.375rem;
}
.field input {
width: 100%;
padding: 0.6rem 0.75rem;
background: var(--surface-hover);
border: 1px solid var(--border);
border-radius: 8px;
color: var(--text);
font-size: 0.9375rem;
font-family: inherit;
outline: none;
transition: border-color 0.15s;
}
.field input:focus { border-color: var(--accent); }
.field input::placeholder { color: var(--text-muted); }
.error-msg {
color: var(--accent);
font-size: 0.8125rem;
font-weight: 500;
margin-bottom: 1rem;
min-height: 1.25rem;
}
.btn-login {
width: 100%;
padding: 0.65rem;
background: var(--accent);
border: none;
border-radius: 8px;
color: #fff;
font-size: 0.9375rem;
font-weight: 500;
cursor: pointer;
transition: background 0.15s;
font-family: inherit;
}
.btn-login:hover { background: var(--accent-hover); }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; }
.login-footer {
text-align: center;
margin-top: 1.25rem;
}
.login-footer a {
color: var(--text-muted);
font-size: 0.8125rem;
text-decoration: none;
transition: color 0.15s;
}
.login-footer a:hover { color: var(--text); }
</style>
</head>
<body>
<div class="login-card">
<div class="login-header">
<div class="login-logo">&#9835;</div>
<h1>Admin Login</h1>
<p>Sign in to manage song requests</p>
</div>
<form id="login-form" onsubmit="return handleLogin(event)">
<div class="field">
<label for="username">Username</label>
<input type="text" id="username" name="username" placeholder="Your admin username" autocomplete="username" required />
</div>
<div class="field">
<label for="key">Admin Key</label>
<input type="password" id="key" name="key" placeholder="Your admin key" autocomplete="current-password" required />
</div>
<div class="error-msg" id="error-msg"></div>
<button type="submit" class="btn-login" id="login-btn">Sign In</button>
</form>
<div class="login-footer">
<a href="/">View dashboard (read-only)</a>
</div>
</div>
<script>
(function initTheme() {
var saved = localStorage.getItem('theme') || 'system';
document.documentElement.setAttribute('data-theme', saved);
})();
if (localStorage.getItem('authToken')) {
window.location.href = '/';
}
function handleLogin(e) {
e.preventDefault();
var btn = document.getElementById('login-btn');
var errEl = document.getElementById('error-msg');
var username = document.getElementById('username').value.trim();
var key = document.getElementById('key').value;
if (!username || !key) {
errEl.textContent = 'Both fields are required.';
return false;
}
btn.disabled = true;
btn.textContent = 'Signing in...';
errEl.textContent = '';
fetch('/api/auth/login', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({username: username, key: key})
})
.then(function(r) { return r.json().then(function(d) { return {ok: r.ok, data: d}; }); })
.then(function(res) {
if (res.ok && res.data.token) {
localStorage.setItem('authToken', res.data.token);
localStorage.setItem('adminUsername', res.data.username);
window.location.href = '/';
} else {
errEl.textContent = res.data.error || 'Login failed.';
btn.disabled = false;
btn.textContent = 'Sign In';
}
})
.catch(function() {
errEl.textContent = 'Connection error. Try again.';
btn.disabled = false;
btn.textContent = 'Sign In';
});
return false;
}
</script>
</body>
</html>