Show sourcecode
The following files exists in this folder. Click to view.
login.php
logout.php
register.php
login.php
81 lines UTF-8 Windows (CRLF)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
<?php
declare(strict_types=1);
require_once __DIR__ . '/../includes/functions.php';
startAppSession();
require_once __DIR__ . '/../includes/auth.php';
requireGuest();
$error = '';
$flash = getFlash();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
verifyCsrf();
$email = $_POST['email'] ?? '';
$password = $_POST['password'] ?? '';
if (loginUser($email, $password)) {
redirect('/index.php');
}
$error = 'Fel e-post eller lösenord.';
}
$csrf = csrfToken();
?>
<!doctype html>
<html lang="sv">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Smartkortet">
<meta name="theme-color" content="#0b1220">
<title>Logga in | Smartkortet</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="<?= e(url('assets/css/style.css')) ?>">
<link rel="icon" href="<?= e(url('assets/icon.svg')) ?>" type="image/svg+xml">
<link rel="shortcut icon" href="<?= e(url('assets/icon.svg')) ?>" type="image/svg+xml">
<link rel="apple-touch-icon" sizes="180x180" href="<?= e(url('assets/icon-180.png')) ?>">
<link rel="apple-touch-icon" sizes="512x512" href="<?= e(url('assets/icon-512.png')) ?>">
</head>
<body data-theme="dark">
<main class="auth-shell">
<section class="card auth-card">
<h1>Välkommen</h1>
<p class="subtitle">Logga in för att se saldo och dagens budget.</p>
<?php if ($flash): ?>
<div class="notice <?= e($flash['type']) ?>"><?= e($flash['message']) ?></div>
<?php endif; ?>
<?php if ($error !== ''): ?>
<div class="notice error"><?= e($error) ?></div>
<?php endif; ?>
<form method="post" class="stack">
<input type="hidden" name="csrf_token" value="<?= e($csrf) ?>">
<label class="field">
<span>E-post</span>
<input type="email" name="email" required>
</label>
<label class="field">
<span>Lösenord</span>
<input type="password" name="password" required>
</label>
<button class="btn" type="submit">Logga in</button>
</form>
<p class="auth-switch">Har du inget konto? <a href="<?= e(url('auth/register.php')) ?>">Skapa konto</a></p>
</section>
</main>
</body>
</html>