Files
org-parking/frontend/pages/landing.html
Stefano Manfredi ce9e2fdf2a fix landing page
2025-12-02 23:18:43 +00:00

91 lines
3.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>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>Parking Manager</h1>
<p>Manage team presence and parking assignments</p>
</div>
<div id="authButtons" style="display: flex; flex-direction: column; gap: 1rem;">
<!-- Buttons will be populated by JavaScript based on auth mode -->
<div class="loading">Loading...</div>
</div>
</div>
</div>
<script>
async function init() {
const buttonsDiv = document.getElementById('authButtons');
// Check if already authenticated
// Check JWT token first
if (localStorage.getItem('access_token')) {
window.location.href = '/presence';
return;
}
// Check Authelia (backend will read headers)
try {
const meResponse = await fetch('/api/auth/me');
if (meResponse.ok) {
window.location.href = '/presence';
return;
}
} catch (e) {
// Not authenticated, continue
}
// Get auth configuration
try {
const configResponse = await fetch('/api/auth/config');
const config = await configResponse.json();
if (config.authelia_enabled) {
// Authelia mode: Login goes to Authelia, Register goes to external portal
let buttons = '';
if (config.login_url) {
// Redirect to Authelia login with return URL
const returnUrl = encodeURIComponent(window.location.origin + '/presence');
buttons += `<a href="${config.login_url}?rd=${returnUrl}" class="btn btn-dark btn-full">Sign In</a>`;
} else {
// No login URL configured - just try to access the app (Authelia will intercept)
buttons += `<a href="/presence" class="btn btn-dark btn-full">Sign In</a>`;
}
if (config.registration_url) {
buttons += `<a href="${config.registration_url}" class="btn btn-secondary btn-full" target="_blank">Create Account</a>`;
buttons += `<p class="auth-footer" style="margin-top: 0.5rem; text-align: center; font-size: 0.875rem; color: #666;">Registration requires admin approval</p>`;
}
buttonsDiv.innerHTML = buttons;
} else {
// Standalone mode: Local login and registration
buttonsDiv.innerHTML = `
<a href="/login" class="btn btn-dark btn-full">Sign In</a>
<a href="/register" class="btn btn-secondary btn-full">Create Account</a>
`;
}
} catch (e) {
// Fallback to standalone mode
buttonsDiv.innerHTML = `
<a href="/login" class="btn btn-dark btn-full">Sign In</a>
<a href="/register" class="btn btn-secondary btn-full">Create Account</a>
`;
}
}
init();
</script>
</body>
</html>