This commit is contained in:
2025-12-30 02:56:46 +01:00
parent b3e14d3dab
commit 265a2ac10b
3 changed files with 14 additions and 117 deletions

View File

@@ -1,39 +1,9 @@
<?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);
$res = $auth->login($email, $password);
if ($res['status'] === 'pending') {
$code = $auth->createVerifyCode($res['id'], $email);
$mailer = new \App\Mailer($app);
$mailer->sendTemplate('registration_confirm', $email, [
'code' => $code,
'display_name' => $email,
]);
$_SESSION['verify_email'] = $email;
$app->flash()->set('info', 'Bitte bestätige deine Registrierung mit dem Code aus der E-Mail.');
redirect('/verify');
}
$_SESSION['user_id'] = $res['id'];
$app->flash()->set('success', 'Erfolgreich angemeldet.');
redirect('/dashboard');
} catch (\Throwable $e) {
$error = $e->getMessage();
}
}
$vm = \App\AccountPages::login($app);
$flash = $vm['flash'] ?? null;
$error = $vm['error'] ?? '';
$emailPrefill = $vm['emailPrefill'] ?? '';
?>
<main class="auth-wrap">
<div class="container auth-grid">