- Replace nav user area with display name (non-clickable), gear settings modal, admin button (admins only), and logout button - Settings modal handles display name, timezone, and password change - Add admin.html + admin.js: user table with reset PW, disable/enable, login-as (impersonation), and delete; return-to-admin flow in nav - Add is_admin to UserResponse so frontend can gate the Admin button - Fix all db.begin() bugs in admin.py and users.py (transaction already active from get_current_user query; use commit() directly instead) - Add email-validator and pin bcrypt==4.0.1 for passlib compatibility - Add escHtml() to api.js and admin API namespace - Group nav brand + links in nav-left for left-aligned layout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
84 lines
2.6 KiB
HTML
84 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Login — Bourbonacci</title>
|
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🥃</text></svg>" />
|
|
<link rel="stylesheet" href="/css/style.css" />
|
|
</head>
|
|
<body>
|
|
|
|
<nav>
|
|
<div class="nav-left">
|
|
<a href="/index.html" class="nav-brand">🥃 Bourbonacci</a>
|
|
<div class="nav-links" id="nav-links"></div>
|
|
</div>
|
|
<div id="nav-user"></div>
|
|
</nav>
|
|
|
|
<div class="auth-wrap">
|
|
<div class="auth-logo">
|
|
<h1>Welcome Back</h1>
|
|
<p>Sign in to manage your infinity bottle</p>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div id="alert"></div>
|
|
<form id="login-form">
|
|
<div class="form-group">
|
|
<label for="email">Email</label>
|
|
<input type="email" id="email" autocomplete="email" required placeholder="you@example.com" />
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="password">Password</label>
|
|
<input type="password" id="password" autocomplete="current-password" required placeholder="••••••••" />
|
|
</div>
|
|
<button type="submit" class="btn btn-primary" style="width:100%;margin-top:.5rem" id="submit-btn">Sign In</button>
|
|
</form>
|
|
<hr class="divider" />
|
|
<p style="text-align:center;color:var(--cream-dim);font-size:.9rem">
|
|
Don't have an account? <a href="/register.html" style="color:var(--amber)">Register</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="/js/api.js"></script>
|
|
<script src="/js/auth.js"></script>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
Auth.redirectIfLoggedIn();
|
|
Auth.renderNav();
|
|
|
|
const form = document.getElementById('login-form');
|
|
const alert = document.getElementById('alert');
|
|
const btn = document.getElementById('submit-btn');
|
|
|
|
form.addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
alert.innerHTML = '';
|
|
btn.disabled = true;
|
|
btn.textContent = 'Signing in…';
|
|
|
|
try {
|
|
const email = document.getElementById('email').value.trim();
|
|
const password = document.getElementById('password').value;
|
|
const data = await API.auth.login(email, password);
|
|
Auth.saveToken(data.access_token);
|
|
|
|
// Pre-fetch user info so nav renders immediately
|
|
const user = await API.users.me();
|
|
Auth.saveUser(user);
|
|
|
|
window.location.href = '/dashboard.html';
|
|
} catch (err) {
|
|
alert.innerHTML = `<div class="alert alert-error">${err.message}</div>`;
|
|
btn.disabled = false;
|
|
btn.textContent = 'Sign In';
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|