Initial version upload

This commit is contained in:
Michael Staake
2025-11-03 11:04:46 -08:00
parent 8a3c48b98a
commit 0083f20e8c
26 changed files with 2281 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
<?php
class AuthController extends Controller {
public function login(): void {
$this->requireSetup();
if (isset($_SESSION['user_id'])) {
$this->redirect('/home');
return;
}
$this->view('login');
}
public function authenticate(): void {
$this->requireSetup();
$password = $_POST['password'] ?? '';
if (empty($password)) {
$_SESSION['error'] = 'Password is required';
$this->redirect('/login');
return;
}
$user = new User();
if ($user->verifyPassword($password)) {
$_SESSION['user_id'] = $user->getId();
$this->redirect('/home');
} else {
$_SESSION['error'] = 'Invalid password';
$this->redirect('/login');
}
}
public function logout(): void {
session_destroy();
$this->redirect('/login');
}
}