Veranstaltungen-APP/resources/views/login.html

171 lines
5.2 KiB
HTML

<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Veranstaltungen</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.container {
width: 100%;
max-width: 400px;
}
.card {
background: white;
border-radius: 10px;
padding: 40px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
h1 {
text-align: center;
color: #333;
margin-bottom: 30px;
font-size: 28px;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
color: #555;
font-weight: 600;
margin-bottom: 8px;
}
input {
width: 100%;
padding: 12px;
border: 2px solid #e0e0e0;
border-radius: 5px;
font-size: 14px;
transition: border-color 0.3s;
}
input:focus {
outline: none;
border-color: #667eea;
}
.btn {
width: 100%;
padding: 12px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: transform 0.2s;
margin-top: 10px;
}
.btn:hover {
transform: translateY(-2px);
}
.error {
color: #dc3545;
font-size: 13px;
margin-top: 5px;
}
.success {
color: #28a745;
padding: 12px;
background: #d4edda;
border-radius: 5px;
margin-bottom: 20px;
}
.link {
text-align: center;
margin-top: 20px;
color: #666;
}
.link a {
color: #667eea;
text-decoration: none;
font-weight: 600;
}
.link a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<div class="card">
<h1>Login</h1>
<form id="loginForm">
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" name="email" required>
<div class="error" id="error-email"></div>
</div>
<div class="form-group">
<label for="password">Passwort</label>
<input type="password" id="password" name="password" required>
<div class="error" id="error-password"></div>
</div>
<button type="submit" class="btn">Einloggen</button>
<div class="error" id="error-general"></div>
<div class="success" id="success-message" style="display: none;"></div>
</form>
<div class="link">
Noch kein Konto? <a href="/register">Hier registrieren</a>
</div>
</div>
</div>
<script>
document.getElementById('loginForm').addEventListener('submit', async (e) => {
e.preventDefault();
const formData = {
email: document.getElementById('email').value,
password: document.getElementById('password').value,
};
try {
const response = await fetch('/api/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(formData),
});
const data = await response.json();
if (!response.ok) {
document.getElementById('error-general').textContent = data.message || 'Login fehlgeschlagen';
return;
}
// Erfolgreich - Token speichern und weiterleiten
localStorage.setItem('auth_token', data.token);
localStorage.setItem('user', JSON.stringify(data.user));
document.getElementById('success-message').textContent = 'Login erfolgreich! Weitergeleitet...';
document.getElementById('success-message').style.display = 'block';
setTimeout(() => {
window.location.href = '/';
}, 1500);
} catch (error) {
document.getElementById('error-general').textContent = 'Ein Fehler ist aufgetreten: ' + error.message;
}
});
</script>
</body>
</html>