- Add about.html explaining infinity bottles, why to track, how to start - Hero shows "What is it?" + "Track Your Bottle" when logged out; hides about button when logged in - Redirect after login goes to index (community page) instead of dashboard - redirectIfLoggedIn also sends to index 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 = '/index.html';
|
|
} catch (err) {
|
|
alert.innerHTML = `<div class="alert alert-error">${err.message}</div>`;
|
|
btn.disabled = false;
|
|
btn.textContent = 'Sign In';
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|