84 lines
2.8 KiB
HTML
84 lines
2.8 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 - Parking Manager</title>
|
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
|
<link rel="stylesheet" href="/css/styles.css">
|
|
</head>
|
|
<body>
|
|
<div class="auth-container">
|
|
<div class="auth-card">
|
|
<div class="auth-header">
|
|
<h1>Welcome Back</h1>
|
|
<p>Sign in to your account</p>
|
|
</div>
|
|
|
|
<div id="errorMessage"></div>
|
|
|
|
<form id="loginForm">
|
|
<div class="form-group">
|
|
<label for="email">Email</label>
|
|
<input type="email" id="email" required autocomplete="email">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="password">Password</label>
|
|
<input type="password" id="password" required autocomplete="current-password">
|
|
</div>
|
|
<button type="submit" class="btn btn-dark btn-full">Sign In</button>
|
|
</form>
|
|
|
|
<div class="auth-footer">
|
|
Don't have an account? <a href="/register">Sign up</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="/js/api.js"></script>
|
|
<script>
|
|
async function init() {
|
|
// Redirect if already logged in
|
|
if (api.isAuthenticated()) {
|
|
window.location.href = '/presence';
|
|
return;
|
|
}
|
|
|
|
// Check auth mode - if Authelia enabled, redirect to Authelia login
|
|
try {
|
|
const configResponse = await fetch('/api/auth/config');
|
|
const config = await configResponse.json();
|
|
|
|
if (config.authelia_enabled && config.login_url) {
|
|
const returnUrl = encodeURIComponent(window.location.origin + '/presence');
|
|
window.location.href = `${config.login_url}?rd=${returnUrl}`;
|
|
return;
|
|
}
|
|
} catch (e) {
|
|
// Continue with local login
|
|
}
|
|
}
|
|
|
|
init();
|
|
|
|
document.getElementById('loginForm').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
|
|
const email = document.getElementById('email').value;
|
|
const password = document.getElementById('password').value;
|
|
const errorDiv = document.getElementById('errorMessage');
|
|
|
|
errorDiv.innerHTML = '';
|
|
|
|
const result = await api.login(email, password);
|
|
|
|
if (result.success) {
|
|
window.location.href = '/presence';
|
|
} else {
|
|
errorDiv.innerHTML = `<div class="message error">${result.error}</div>`;
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|