Nofu/template/default/login.php

47 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2024-06-14 17:20:01 +02:00
<?php
use Login\Login;
use Utils\CsrfToken;
use Utils\Debug;
$error = null;
$breadcrumbs = ' / Login';
$debug = new Debug;
if (!empty($_POST)) {
if (empty($_POST['login']) || empty($_POST['password'])) {
$error = 'Please fill login and password.';
} else {
$login = new Login;
if (CsrfToken::validateToken($_POST['token'])) {
if ($login->LogIn($_POST['login'], $_POST['password'])) {
header('Location: index.php');
} else {
$error = 'Wrong password ar login.';
}
} else {
$error = 'Error 06 : Wrong token';
}
}
}
require 'header.php';
?>
<div class="titleBar">
<h1><?= $config['title']; ?> / Login</h1>
</div>
<form action="?" class="login" method="post">
<div class="alert" style="color: red;">
<?= $error; ?>
</div>
<label>Login</label>
<input type="text" name="login" required>
<label>Password</label>
<input type="password" name="password" required>
<input type="hidden" name="token" value="<?= CsrfToken::generateToken(); ?>">
<button type="submit">Login</button>
</form>
</body>
</html>