89 lines
3.1 KiB
HTML
89 lines
3.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Register - 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>Create Account</h1>
|
|
<p>Sign up for a new account</p>
|
|
</div>
|
|
|
|
<div id="errorMessage"></div>
|
|
|
|
<form id="registerForm">
|
|
<div class="form-group">
|
|
<label for="name">Full Name</label>
|
|
<input type="text" id="name" required autocomplete="name">
|
|
</div>
|
|
<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="new-password" minlength="8">
|
|
<small>Minimum 8 characters</small>
|
|
</div>
|
|
<button type="submit" class="btn btn-dark btn-full">Create Account</button>
|
|
</form>
|
|
|
|
<div class="auth-footer">
|
|
Already have an account? <a href="/login">Sign in</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 external registration portal
|
|
try {
|
|
const configResponse = await fetch('/api/auth/config');
|
|
const config = await configResponse.json();
|
|
|
|
if (config.authelia_enabled && config.registration_url) {
|
|
window.location.href = config.registration_url;
|
|
return;
|
|
}
|
|
} catch (e) {
|
|
// Continue with local registration
|
|
}
|
|
}
|
|
|
|
init();
|
|
|
|
document.getElementById('registerForm').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
|
|
const name = document.getElementById('name').value;
|
|
const email = document.getElementById('email').value;
|
|
const password = document.getElementById('password').value;
|
|
const errorDiv = document.getElementById('errorMessage');
|
|
|
|
errorDiv.innerHTML = '';
|
|
|
|
const result = await api.register(email, password, name);
|
|
|
|
if (result.success) {
|
|
window.location.href = '/presence';
|
|
} else {
|
|
errorDiv.innerHTML = `<div class="message error">${result.error}</div>`;
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|