150 lines
4.4 KiB
HTML
150 lines
4.4 KiB
HTML
<!doctype html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>Login</title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
|
|
<style>
|
|
body {
|
|
font-family: 'Inter', sans-serif;
|
|
background: #f4f6f8;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
min-height: 100vh;
|
|
margin: 0;
|
|
}
|
|
|
|
.login-container {
|
|
background: white;
|
|
padding: 32px;
|
|
border-radius: 12px;
|
|
box-shadow: 0 8px 24px rgba(0,0,0,0.1);
|
|
max-width: 400px;
|
|
width: 100%;
|
|
}
|
|
|
|
h1 {
|
|
font-size: 24px;
|
|
margin-bottom: 24px;
|
|
text-align: center;
|
|
color: #333;
|
|
}
|
|
|
|
label {
|
|
font-weight: 600;
|
|
display: block;
|
|
margin-bottom: 4px;
|
|
color: #444;
|
|
}
|
|
|
|
input {
|
|
width: 100%;
|
|
padding: 10px;
|
|
margin-bottom: 16px;
|
|
border: 1px solid #ccc;
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
button {
|
|
width: 100%;
|
|
padding: 12px;
|
|
background-color: #4F46E5;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-size: 16px;
|
|
cursor: pointer;
|
|
font-weight: 600;
|
|
}
|
|
|
|
button:hover {
|
|
background-color: #4338ca;
|
|
}
|
|
|
|
.msg {
|
|
margin-top: 16px;
|
|
padding: 12px;
|
|
border-radius: 6px;
|
|
font-size: 14px;
|
|
display: none;
|
|
}
|
|
|
|
.msg.error {
|
|
background-color: #fee2e2;
|
|
color: #b91c1c;
|
|
border: 1px solid #fca5a5;
|
|
}
|
|
|
|
.msg.success {
|
|
background-color: #dcfce7;
|
|
color: #166534;
|
|
border: 1px solid #86efac;
|
|
}
|
|
|
|
#captcha-container {
|
|
margin: 16px 0;
|
|
display: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-container">
|
|
<h1>Login</h1>
|
|
<form id="login">
|
|
<label for="username">Benutzername</label>
|
|
<input id="username" name="username" required />
|
|
<label for="password">Passwort</label>
|
|
<input id="password" name="password" type="password" required />
|
|
<div id="captcha-container">
|
|
<div class="h-captcha" data-sitekey="10000000-ffff-ffff-ffff-000000000001"></div>
|
|
</div>
|
|
<button type="submit">Einloggen</button>
|
|
</form>
|
|
<div class="msg" id="msg"></div>
|
|
</div>
|
|
<script src="https://hcaptcha.com/1/api.js" async defer></script>
|
|
<script>
|
|
const form = document.getElementById('login');
|
|
const msg = document.getElementById('msg');
|
|
const captchaContainer = document.getElementById('captcha-container');
|
|
form.addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
msg.style.display = 'none';
|
|
const username = document.getElementById('username').value;
|
|
const password = document.getElementById('password').value;
|
|
const captcha = hcaptcha.getResponse();
|
|
const body = { username, password, captcha };
|
|
try {
|
|
const res = await fetch('/login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(body)
|
|
});
|
|
const data = await res.json();
|
|
msg.style.display = 'block';
|
|
if (res.ok && data.ok) {
|
|
msg.textContent = '✅ Erfolgreich eingeloggt!';
|
|
msg.className = 'msg success';
|
|
hcaptcha.reset();
|
|
} else {
|
|
msg.textContent = '❌ ' + (data.error || 'Login fehlgeschlagen');
|
|
msg.className = 'msg error';
|
|
if (data.requiresCaptcha) {
|
|
captchaContainer.style.display = 'block';
|
|
hcaptcha.reset();
|
|
}
|
|
}
|
|
} catch (err) {
|
|
msg.textContent = '⚠️ Netzwerkfehler: ' + err.message;
|
|
msg.className = 'msg error';
|
|
msg.style.display = 'block';
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |