instances added god may help

This commit is contained in:
2026-02-23 12:58:19 +01:00
parent 25370a1a55
commit 99db252f60
290 changed files with 9858 additions and 4914 deletions

View File

@@ -6,7 +6,7 @@ use MintyPHP\DB;
class PasswordResetRepository
{
private static function unwrapList($rows): array
private function unwrapList($rows): array
{
if (!is_array($rows)) {
return [];
@@ -21,7 +21,7 @@ class PasswordResetRepository
return $list;
}
public static function create(int $userId, string $codeHash, string $expiresAt): ?int
public function create(int $userId, string $codeHash, string $expiresAt): ?int
{
$id = DB::insert(
'insert into password_resets (user_id, code_hash, expires_at, attempts, used_at, created) values (?,?,?,?,NULL,NOW())',
@@ -33,7 +33,7 @@ class PasswordResetRepository
return $id ? (int) $id : null;
}
public static function invalidateForUser(int $userId): bool
public function invalidateForUser(int $userId): bool
{
$result = DB::update(
'update password_resets set used_at = NOW() where user_id = ? and used_at is null',
@@ -42,7 +42,7 @@ class PasswordResetRepository
return $result !== false;
}
public static function findActiveByUserId(int $userId): ?array
public function findActiveByUserId(int $userId): ?array
{
$row = DB::selectOne(
'select id, user_id, code_hash, expires_at, attempts, used_at from password_resets where user_id = ? and used_at is null and expires_at > UTC_TIMESTAMP() order by id desc limit 1',
@@ -54,7 +54,7 @@ class PasswordResetRepository
return $row['password_resets'];
}
public static function findById(int $id): ?array
public function findById(int $id): ?array
{
$row = DB::selectOne(
'select id, user_id, code_hash, expires_at, attempts, used_at from password_resets where id = ? limit 1',
@@ -66,7 +66,7 @@ class PasswordResetRepository
return $row['password_resets'];
}
public static function incrementAttempts(int $id): bool
public function incrementAttempts(int $id): bool
{
$result = DB::update(
'update password_resets set attempts = attempts + 1 where id = ?',
@@ -75,7 +75,7 @@ class PasswordResetRepository
return $result !== false;
}
public static function markUsed(int $id): bool
public function markUsed(int $id): bool
{
$result = DB::update(
'update password_resets set used_at = NOW() where id = ?',
@@ -84,7 +84,7 @@ class PasswordResetRepository
return $result !== false;
}
public static function listByUserId(int $userId, int $limit = 20): array
public function listByUserId(int $userId, int $limit = 20): array
{
if ($userId <= 0) {
return [];
@@ -99,6 +99,6 @@ class PasswordResetRepository
(string) $userId,
(string) $limit
);
return self::unwrapList($rows);
return $this->unwrapList($rows);
}
}