send
This commit is contained in:
@@ -1,17 +1,49 @@
|
||||
<?php
|
||||
$app = app();
|
||||
$flash = $app->flash()->get();
|
||||
$isLoggedIn = isset($_SESSION['user_id']);
|
||||
$error = '';
|
||||
$emailPrefill = '';
|
||||
|
||||
if ($isLoggedIn) {
|
||||
redirect('/dashboard');
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$email = trim((string)($_POST['email'] ?? ''));
|
||||
$emailPrefill = $email;
|
||||
$password = (string)($_POST['password'] ?? '');
|
||||
try {
|
||||
$auth = new \App\Auth($app);
|
||||
$userId = $auth->login($email, $password);
|
||||
$_SESSION['user_id'] = $userId;
|
||||
$app->flash()->set('success', 'Erfolgreich angemeldet.');
|
||||
redirect('/dashboard');
|
||||
} catch (\Throwable $e) {
|
||||
$error = $e->getMessage();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<main class="auth-wrap">
|
||||
<div class="container auth-grid">
|
||||
<section class="card auth-card">
|
||||
<div class="badge">Login</div>
|
||||
<h1 class="mt-1" style="margin: 12px 0;">Willkommen zurück</h1>
|
||||
<p class="muted">Melde dich an, um Events zu erstellen, teilzunehmen und dein Profil zu verwalten.</p>
|
||||
<form class="stack gap-12" style="margin-top: 14px;">
|
||||
<?php if ($flash): ?>
|
||||
<div class="toast-bar" style="margin-top: 10px;"><?= htmlspecialchars($flash['message'], ENT_QUOTES) ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($error): ?>
|
||||
<div class="toast-bar" style="margin-top: 10px; border-color:#f87171; color:#991b1b;">Fehler: <?= htmlspecialchars($error, ENT_QUOTES) ?></div>
|
||||
<?php endif; ?>
|
||||
<form class="stack gap-12" style="margin-top: 14px;" method="post" action="/login">
|
||||
<div class="stack gap-6">
|
||||
<label class="label" for="loginEmail">E-Mail</label>
|
||||
<input id="loginEmail" name="email" class="input" type="email" required placeholder="du@example.com">
|
||||
<input id="loginEmail" name="email" class="input" type="email" required placeholder="du@example.com" value="<?= htmlspecialchars($emailPrefill, ENT_QUOTES) ?>">
|
||||
</div>
|
||||
<div class="stack gap-6">
|
||||
<label class="label" for="loginPassword">Passwort</label>
|
||||
<input id="loginPassword" name="password" class="input" type="password" required placeholder="********">
|
||||
<input id="loginPassword" name="password" class="input" type="password" required placeholder="********" autocomplete="current-password">
|
||||
</div>
|
||||
<div style="display:flex; justify-content:space-between; align-items:center; flex-wrap: wrap; gap: 8px;">
|
||||
<label style="display:flex; gap:8px; align-items:center; font-size:14px; color: var(--color-muted);">
|
||||
|
||||
Reference in New Issue
Block a user