First
This commit is contained in:
53
backend/public/login/index.html
Normal file
53
backend/public/login/index.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Freundesbuch</title>
|
||||
<link rel="stylesheet" href="/assets/style.css" />
|
||||
<style>
|
||||
body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
|
||||
.login-card { width: 100%; max-width: 380px; text-align: center; position: relative; }
|
||||
.login-card .tape { top: -12px; left: 50%; transform: translateX(-50%) rotate(-3deg); }
|
||||
.book-emoji { font-size: 3rem; display: block; margin-bottom: 0.1em; }
|
||||
form { margin-top: 1.2em; display: flex; flex-direction: column; gap: 0.8em; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="card login-card">
|
||||
<div class="tape"></div>
|
||||
<span class="book-emoji">📖</span>
|
||||
<h1>Freundesbuch</h1>
|
||||
<p class="muted">Gib das Passwort ein, um hineinzuschauen.</p>
|
||||
<form id="loginForm">
|
||||
<input type="password" id="password" placeholder="Passwort" autofocus required />
|
||||
<button type="submit">Aufschlagen</button>
|
||||
</form>
|
||||
<div id="err"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById('loginForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const password = document.getElementById('password').value;
|
||||
const errBox = document.getElementById('err');
|
||||
errBox.innerHTML = '';
|
||||
try {
|
||||
const res = await fetch('/api/login', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ password }),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!res.ok) {
|
||||
errBox.innerHTML = `<p class="error-msg">${data.error || 'Fehler beim Anmelden.'}</p>`;
|
||||
return;
|
||||
}
|
||||
window.location.href = '/admin';
|
||||
} catch (err) {
|
||||
errBox.innerHTML = '<p class="error-msg">Verbindung fehlgeschlagen.</p>';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user