send
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
<?php
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
redirect('/login');
|
||||
}
|
||||
?>
|
||||
<main class="section">
|
||||
<div class="container" style="display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px;">
|
||||
<div>
|
||||
@@ -61,7 +66,7 @@
|
||||
<div class="card dash-card">
|
||||
<div class="badge">Eigenes Event</div>
|
||||
<h3>Neuen Termin erstellen</h3>
|
||||
<form class="stack gap-12" style="margin-top: 10px;">
|
||||
<form class="stack gap-12" style="margin-top: 10px;" method="post" action="/dashboard#events">
|
||||
<div class="form-grid">
|
||||
<div class="stack gap-6">
|
||||
<label class="label" for="evTitle">Titel</label>
|
||||
|
||||
@@ -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);">
|
||||
|
||||
@@ -1,26 +1,67 @@
|
||||
<?php
|
||||
$app = app();
|
||||
$flash = $app->flash()->get();
|
||||
$isLoggedIn = isset($_SESSION['user_id']);
|
||||
$error = '';
|
||||
$displayName = '';
|
||||
$email = '';
|
||||
|
||||
if ($isLoggedIn) {
|
||||
redirect('/dashboard');
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$displayName = trim((string)($_POST['display_name'] ?? ''));
|
||||
$email = trim((string)($_POST['email'] ?? ''));
|
||||
$password = (string)($_POST['password'] ?? '');
|
||||
$password2 = (string)($_POST['password_confirm'] ?? '');
|
||||
|
||||
if ($password !== $password2) {
|
||||
$error = 'Passwörter stimmen nicht überein.';
|
||||
} elseif (strlen($password) < 8) {
|
||||
$error = 'Passwort muss mindestens 8 Zeichen haben.';
|
||||
} else {
|
||||
try {
|
||||
$auth = new \App\Auth($app);
|
||||
$userId = $auth->register($displayName, $email, $password);
|
||||
$_SESSION['user_id'] = $userId;
|
||||
$app->flash()->set('success', 'Willkommen! Dein Account wurde erstellt.');
|
||||
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">Registrierung</div>
|
||||
<h1 class="mt-1" style="margin: 12px 0;">Jetzt Account anlegen</h1>
|
||||
<p class="muted">Registriere dich mit wenigen Angaben. Alles Weitere pflegst du später im Mitgliederbereich.</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="/register">
|
||||
<div class="stack gap-6">
|
||||
<label class="label" for="regName">Anzeigename</label>
|
||||
<input id="regName" name="display_name" class="input" required placeholder="z. B. Papa Alex">
|
||||
<input id="regName" name="display_name" class="input" required placeholder="z. B. Papa Alex" value="<?= htmlspecialchars($displayName ?? '', ENT_QUOTES) ?>">
|
||||
</div>
|
||||
<div class="stack gap-6">
|
||||
<label class="label" for="regEmail">E-Mail</label>
|
||||
<input id="regEmail" name="email" class="input" type="email" required placeholder="du@example.com">
|
||||
<input id="regEmail" name="email" class="input" type="email" required placeholder="du@example.com" value="<?= htmlspecialchars($email ?? '', ENT_QUOTES) ?>">
|
||||
</div>
|
||||
<div class="form-grid">
|
||||
<div class="stack gap-6">
|
||||
<label class="label" for="regPassword">Passwort</label>
|
||||
<input id="regPassword" name="password" class="input" type="password" required placeholder="********">
|
||||
<input id="regPassword" name="password" class="input" type="password" required placeholder="********" autocomplete="new-password">
|
||||
</div>
|
||||
<div class="stack gap-6">
|
||||
<label class="label" for="regPassword2">Passwort bestätigen</label>
|
||||
<input id="regPassword2" name="password_confirm" class="input" type="password" required placeholder="********">
|
||||
<input id="regPassword2" name="password_confirm" class="input" type="password" required placeholder="********" autocomplete="new-password">
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn block" type="submit">Account erstellen</button>
|
||||
|
||||
Reference in New Issue
Block a user