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

36
models/User.php Normal file
View File

@@ -0,0 +1,36 @@
<?php
class User {
private PDO $db;
public function __construct() {
$this->db = Database::getInstance();
}
public function verifyPassword(string $password): bool {
$stmt = $this->db->query("SELECT password_hash FROM users LIMIT 1");
$user = $stmt->fetch();
if (!$user) {
return false;
}
return password_verify($password, $user['password_hash']);
}
public function updatePassword(string $newPassword): bool {
try {
$stmt = $this->db->prepare("UPDATE users SET password_hash = ?, updated_at = CURRENT_TIMESTAMP");
return $stmt->execute([password_hash($newPassword, PASSWORD_DEFAULT)]);
} catch (PDOException $e) {
error_log('Password update failed: ' . $e->getMessage());
return false;
}
}
public function getId(): ?int {
$stmt = $this->db->query("SELECT id FROM users LIMIT 1");
$user = $stmt->fetch();
return $user ? (int)$user['id'] : null;
}
}