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,49 @@
<?php
class SetupController extends Controller {
public function index(): void {
// Check if database is already initialized
if (Database::isInitialized()) {
$this->redirect('/home');
return;
}
$this->view('setup');
}
public function setup(): void {
if (Database::isInitialized()) {
$this->redirect('/home');
return;
}
$password = $_POST['password'] ?? '';
$confirmPassword = $_POST['confirm_password'] ?? '';
if (empty($password)) {
$_SESSION['error'] = 'Password is required';
$this->redirect('/setup');
return;
}
if ($password !== $confirmPassword) {
$_SESSION['error'] = 'Passwords do not match';
$this->redirect('/setup');
return;
}
if (strlen($password) < 6) {
$_SESSION['error'] = 'Password must be at least 6 characters';
$this->redirect('/setup');
return;
}
if (Database::initialize($password)) {
$_SESSION['success'] = 'Setup completed successfully! Please login.';
$this->redirect('/login');
} else {
$_SESSION['error'] = 'Setup failed. Please try again.';
$this->redirect('/setup');
}
}
}