107 lines
4.3 KiB
PHP
107 lines
4.3 KiB
PHP
<?php /* Name: login.php
|
|
Beschreibung: Login-Seite (Authorisierung) */
|
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/general_files/ini/parameters.php';
|
|
require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/general_files/ini/functions.php';
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
|
|
$pdo = require_once($_SERVER['DOCUMENT_ROOT']."/intranet_repo/general_files/ini/database.php");
|
|
|
|
$sql = "SELECT
|
|
u.*,
|
|
l.password_hash AS password_hash
|
|
FROM
|
|
user_general_information AS u
|
|
INNER JOIN
|
|
user_login AS l ON u.user_id = l.user_id
|
|
WHERE
|
|
u.mail = ?";
|
|
|
|
$stmt = $pdo->prepare($sql);
|
|
$stmt->execute([$_POST["email"]]);
|
|
$user = $stmt->fetch();
|
|
|
|
if ($user) {
|
|
|
|
if (isset($user['password_hash']) && password_verify($_POST["password"], $user["password_hash"])) {
|
|
|
|
session_start();
|
|
session_regenerate_id();
|
|
$_SESSION["user_id"] = $user["user_id"];
|
|
|
|
header("Location: {$g_httpHomePath}");
|
|
exit;
|
|
}
|
|
}
|
|
|
|
$is_invalid = true;
|
|
}
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="de" dir="ltr">
|
|
<head>
|
|
<?php require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/projects/_central/php/html_head.php'; ?>
|
|
|
|
<script src="https://unpkg.com/just-validate@latest/dist/just-validate.production.min.js" defer></script>
|
|
<script src="validation.js" defer></script>
|
|
</head>
|
|
<body>
|
|
<div class="login_panel">
|
|
|
|
<?php if (isset($is_invalid) && $is_invalid): ?>
|
|
<div class="nak-toast nak-toast--error nak-toast--inline" id="nakToastLogin">
|
|
<div class="nak-toast__icon">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="square" stroke-linejoin="miter"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
|
|
</div>
|
|
<span class="nak-toast__text">Ungültiger Login!</span>
|
|
</div>
|
|
<script>requestAnimationFrame(function(){document.getElementById('nakToastLogin').classList.add('nak-toast--visible');});</script>
|
|
<?php endif; ?>
|
|
|
|
<?php if (isset($_GET["message"]) && $_GET["message"] == 1): ?>
|
|
<div class="nak-toast nak-toast--success nak-toast--inline" id="nakToastPw">
|
|
<div class="nak-toast__icon">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="square" stroke-linejoin="miter"><path d="M20 6L9 17l-5-5"/></svg>
|
|
</div>
|
|
<span class="nak-toast__text">Passwort erfolgreich geändert. Sie können sich jetzt anmelden.</span>
|
|
</div>
|
|
<script>requestAnimationFrame(function(){document.getElementById('nakToastPw').classList.add('nak-toast--visible');});</script>
|
|
<?php endif; ?>
|
|
<div class="login_content">
|
|
<div class="nak-logo-link auth-logo">
|
|
<img class="auth-logo__icon" src="/intranet_repo/projects/_central/img/nak-logo.svg" alt="NAK Logo">
|
|
<div class="auth-logo__text">
|
|
<div class="auth-logo__name">Neuapostolische Kirche</div>
|
|
<div class="auth-logo__gemeinde">Berlin-Reinickendorf</div>
|
|
</div>
|
|
</div>
|
|
<h2>Anmelden</h2>
|
|
|
|
<form method="post">
|
|
<div class="flexcolumn_center">
|
|
<input class="login_field" placeholder="E-Mailadresse" type="email" name="email" id="email"
|
|
value="<?= htmlspecialchars($_POST["email"] ?? "") ?>">
|
|
<input class="login_field" placeholder="Passwort" type="password" name="password" id="password">
|
|
<input class="login_button" type="submit" name="submit" value="Anmelden">
|
|
</div>
|
|
</form>
|
|
<div class="small_text" style="text-align:center;margin-top:24px;color:var(--gray-600);">
|
|
Sie haben noch keinen Account für das Intranet?<br>
|
|
<a href="signup.php">Registrieren</a><br>
|
|
<br>
|
|
Passwort vergessen?<br>
|
|
<a href="reset-password.php">Passwort zurücksetzen</a><br>
|
|
<br>
|
|
Probleme bei der Anmeldung?<br>
|
|
<a href="#" onclick="openContactModal(); return false;">Admin kontaktieren</a>
|
|
</div>
|
|
</div><!-- EOD: login_content -->
|
|
</div><!-- EOD: login_panel -->
|
|
|
|
<?php require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/projects/_central/php/footer.php'; ?>
|
|
|
|
</body>
|
|
</html>
|