rss-reader/templates/login.html.tera
2025-02-03 15:53:28 -08:00

66 lines
2.6 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RSS Reader Login</title>
<link rel="stylesheet" href="/static/css/style.css">
</head>
<div class="login-container">
{% if demo_mode %}
<div class="demo-notice">
<h2>Demo Mode</h2>
<p>RSS Reader is currently running in demo mode. You can log in with these credentials:</p>
<p>Username: <pre style="display: inline">demo</pre></p>
<p>Password: <pre style="display: inline">demo</pre></p>
<p>Note: Any data you create will not be persisted after the application restarts.</p>
</div>
{% endif %}
<form class="login-form" id="loginForm">
<h1>Login</h1>
<div class="form-group">
<label for="username">Username</label>
<input type="text" id="username" name="username" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" required>
</div>
<div class="error-message" id="errorMessage" style="display: none; color: red; margin-bottom: 10px;"></div>
<button type="submit">Log In</button>
</form>
</div>
<script>
document.getElementById('loginForm').addEventListener('submit', async (e) => {
e.preventDefault();
const errorMessage = document.getElementById('errorMessage');
errorMessage.style.display = 'none';
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
try {
const response = await fetch('/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ username, password }),
});
if (response.ok) {
window.location.href = '/';
} else {
errorMessage.textContent = 'Invalid username or password';
errorMessage.style.display = 'block';
}
} catch (error) {
errorMessage.textContent = 'An error occurred. Please try again.';
errorMessage.style.display = 'block';
}
});
</script>
</body>
</html>