CareerBot/templates/admin/login.html
ln0422 501f8985ec Add /careerbot base path for www.ityb.me/careerbot deployment
- Add BASE_PATH config, include all routers with prefix
- Inject {{ base }} Jinja2 global for all template URLs
- Add window.BASE_PATH for static JS files
- Update Nginx to proxy /careerbot/ path
- Add OPS_MANUAL.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 22:07:34 +08:00

60 lines
2.0 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CareerBot Admin - Login</title>
<link rel="stylesheet" href="{{ base }}/static/css/style.css">
</head>
<body>
<div class="login-container">
<div class="login-card">
<h1>Admin Login</h1>
<p>CareerBot Management</p>
<input type="email" id="email" placeholder="Email" autocomplete="email">
<input type="password" id="password" placeholder="Password" autocomplete="current-password">
<button class="btn-primary" onclick="doLogin()">Login</button>
<div class="error-msg" id="error-msg"></div>
</div>
</div>
<script>
const BASE = "{{ base }}";
document.getElementById('password').addEventListener('keydown', e => {
if (e.key === 'Enter') doLogin();
});
async function doLogin() {
const email = document.getElementById('email').value.trim();
const password = document.getElementById('password').value;
const errEl = document.getElementById('error-msg');
errEl.style.display = 'none';
if (!email || !password) {
errEl.textContent = 'Please enter email and password';
errEl.style.display = 'block';
return;
}
try {
const resp = await fetch(BASE + '/api/admin/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password }),
});
if (resp.ok) {
const data = await resp.json();
localStorage.setItem('admin_token', data.access_token);
window.location.href = BASE + '/admin/dashboard';
} else {
errEl.textContent = 'Invalid email or password';
errEl.style.display = 'block';
}
} catch (e) {
errEl.textContent = 'Network error';
errEl.style.display = 'block';
}
}
</script>
</body>
</html>