64 lines
2.4 KiB
PHP
64 lines
2.4 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/app.php';
|
|
|
|
if (is_admin_logged_in()) {
|
|
header('Location: /dashboard.php');
|
|
exit;
|
|
}
|
|
|
|
$error = '';
|
|
$email = admin_email();
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$email = trim((string) ($_POST['email'] ?? ''));
|
|
$password = (string) ($_POST['password'] ?? '');
|
|
|
|
if (attempt_admin_login($email, $password)) {
|
|
set_flash('success', 'Signed in successfully.');
|
|
header('Location: /dashboard.php');
|
|
exit;
|
|
}
|
|
|
|
$error = 'The email or password is incorrect.';
|
|
}
|
|
|
|
render_head(project_name() . ' | Admin login', 'Admin sign-in for reviewing incoming project requests.', true);
|
|
render_navbar('login');
|
|
render_flash_toast();
|
|
?>
|
|
<main class="auth-shell">
|
|
<div class="container py-5 py-lg-6">
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-5 col-xl-4">
|
|
<div class="panel-card p-4 p-lg-5">
|
|
<div class="section-kicker mb-2">Secure area</div>
|
|
<h1 class="h3 mb-2">Admin login</h1>
|
|
<p class="text-secondary mb-4">Sign in to review new requests, open details, and update statuses.</p>
|
|
<?php if ($error !== ''): ?>
|
|
<div class="alert alert-danger" role="alert"><?= e($error) ?></div>
|
|
<?php endif; ?>
|
|
<form method="post" class="vstack gap-3" novalidate>
|
|
<div>
|
|
<label class="form-label" for="email">Email</label>
|
|
<input class="form-control" id="email" name="email" type="email" value="<?= e($email) ?>" required>
|
|
</div>
|
|
<div>
|
|
<label class="form-label" for="password">Password</label>
|
|
<input class="form-control" id="password" name="password" type="password" required>
|
|
</div>
|
|
<button class="btn btn-dark w-100" type="submit">Sign in</button>
|
|
</form>
|
|
<div class="notice-box mt-4">
|
|
<div class="small text-uppercase fw-semibold text-secondary mb-2">Demo credentials</div>
|
|
<div class="d-flex justify-content-between align-items-center gap-3 small border rounded-3 px-3 py-2 mb-2"><span>Email</span><code><?= e(admin_email()) ?></code></div>
|
|
<div class="d-flex justify-content-between align-items-center gap-3 small border rounded-3 px-3 py-2"><span>Password</span><code><?= e(admin_password()) ?></code></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<?php render_footer('login'); ?>
|