170 lines
4.0 KiB
PHP
170 lines
4.0 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
require __DIR__ . '/auth/ldap.php';
|
|
require __DIR__ . '/data/db.php';
|
|
require __DIR__ . '/functions/logging.php';
|
|
require __DIR__ . '/functions/ldap_groups.php';
|
|
|
|
// Bepaal redirect-bestemming
|
|
$redirect = $_GET['redirect'] ?? $_POST['redirect'] ?? 'index.php';
|
|
|
|
// Uitloggen
|
|
if (isset($_POST['logout'])) {
|
|
if (isset($_SESSION['user'])) {
|
|
log_action($pdo, $_SESSION['user']['username'], 'Uitgelogd', 'Login-pagina');
|
|
}
|
|
session_destroy();
|
|
header('Location: ' . $_SERVER['PHP_SELF']);
|
|
exit;
|
|
}
|
|
|
|
// Inloggen
|
|
$error = '';
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['username'], $_POST['password'])) {
|
|
$username = trim($_POST['username']);
|
|
$password = $_POST['password'];
|
|
|
|
$user = ldap_authenticate($username, $password);
|
|
|
|
if ($user) {
|
|
$_SESSION['user'] = $user;
|
|
log_action($pdo, $user['username'], 'Inloggen via LDAP', 'Login-pagina');
|
|
header("Location: $redirect");
|
|
exit;
|
|
} else {
|
|
$error = "Ongeldige gebruikersnaam of wachtwoord.";
|
|
log_action($pdo, $username, 'Mislukte login via LDAP', 'Login-pagina');
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="nl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Inloggen</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
font-family: "Segoe UI", Roboto, sans-serif;
|
|
background: linear-gradient(135deg, #4c8bf5, #6cc2ff);
|
|
height: 100vh;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
}
|
|
|
|
.login-container {
|
|
background: white;
|
|
border-radius: 12px;
|
|
box-shadow: 0 8px 24px rgba(0,0,0,0.15);
|
|
width: 100%;
|
|
max-width: 360px;
|
|
padding: 40px 30px;
|
|
box-sizing: border-box;
|
|
text-align: center;
|
|
animation: fadeIn 0.6s ease;
|
|
}
|
|
|
|
h2 {
|
|
margin-bottom: 20px;
|
|
color: #333;
|
|
font-size: 1.6em;
|
|
}
|
|
|
|
form {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 15px;
|
|
}
|
|
|
|
label {
|
|
text-align: left;
|
|
font-weight: 600;
|
|
font-size: 0.9em;
|
|
color: #444;
|
|
}
|
|
|
|
input[type="text"],
|
|
input[type="password"] {
|
|
padding: 10px;
|
|
font-size: 1em;
|
|
border: 1px solid #ccc;
|
|
border-radius: 6px;
|
|
outline: none;
|
|
transition: border-color 0.2s;
|
|
}
|
|
|
|
input[type="text"]:focus,
|
|
input[type="password"]:focus {
|
|
border-color: #4c8bf5;
|
|
}
|
|
|
|
button {
|
|
background-color: #4c8bf5;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 6px;
|
|
padding: 10px;
|
|
font-size: 1em;
|
|
cursor: pointer;
|
|
transition: background-color 0.2s;
|
|
}
|
|
|
|
button:hover {
|
|
background-color: #3b78e0;
|
|
}
|
|
|
|
.error {
|
|
color: #d93025;
|
|
background-color: #fdecea;
|
|
border: 1px solid #f5c2c0;
|
|
border-radius: 6px;
|
|
padding: 10px;
|
|
margin-bottom: 15px;
|
|
text-align: left;
|
|
font-size: 0.9em;
|
|
}
|
|
|
|
.footer {
|
|
margin-top: 20px;
|
|
font-size: 0.8em;
|
|
color: #777;
|
|
}
|
|
|
|
@keyframes fadeIn {
|
|
from { opacity: 0; transform: translateY(10px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="login-container">
|
|
<h2>Inloggen</h2>
|
|
|
|
<?php if (!empty($error)): ?>
|
|
<div class="error"><?= htmlspecialchars($error) ?></div>
|
|
<?php endif; ?>
|
|
|
|
<form method="post" autocomplete="off">
|
|
<input type="hidden" name="redirect" value="<?= htmlspecialchars($redirect) ?>">
|
|
|
|
<label for="username">Gebruikersnaam</label>
|
|
<input type="text" id="username" name="username" required placeholder="bijv. jansen" autofocus>
|
|
|
|
<label for="password">Wachtwoord</label>
|
|
<input type="password" id="password" name="password" required placeholder="••••••••">
|
|
|
|
<button type="submit">Inloggen</button>
|
|
</form>
|
|
|
|
<div class="footer">
|
|
<p>© <?= date('Y') ?> Lootjes Trekking</p>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|