Repo Interface für tests
This commit is contained in:
@@ -5,7 +5,7 @@ namespace MintyPHP\Repository\Auth;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class ApiTokenRepository
|
||||
class ApiTokenRepository implements ApiTokenRepositoryInterface
|
||||
{
|
||||
private const UUID_REGEX = '/^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i';
|
||||
|
||||
|
||||
44
lib/Repository/Auth/ApiTokenRepositoryInterface.php
Normal file
44
lib/Repository/Auth/ApiTokenRepositoryInterface.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Auth;
|
||||
|
||||
interface ApiTokenRepositoryInterface
|
||||
{
|
||||
public function isUuid(string $value): bool;
|
||||
|
||||
public function create(
|
||||
int $userId,
|
||||
string $name,
|
||||
string $selector,
|
||||
string $tokenHash,
|
||||
?int $tenantId,
|
||||
?string $expiresAt,
|
||||
?int $createdBy
|
||||
): ?int;
|
||||
|
||||
public function findBySelector(string $selector): ?array;
|
||||
|
||||
public function find(int $id): ?array;
|
||||
|
||||
public function findByUuid(string $uuid): ?array;
|
||||
|
||||
public function findByUuidForUser(string $uuid, int $userId): ?array;
|
||||
|
||||
public function updateLastUsed(int $id, string $ip): bool;
|
||||
|
||||
public function revoke(int $id): bool;
|
||||
|
||||
public function revokeByUuidForUser(string $uuid, int $userId): bool;
|
||||
|
||||
public function revokeAllForUser(int $userId, ?int $tenantId = null): int;
|
||||
|
||||
public function revokeAllActiveByAdmin(): int;
|
||||
|
||||
public function listByUserId(int $userId, int $limit = 25): array;
|
||||
|
||||
public function countActiveForUser(int $userId): int;
|
||||
|
||||
public function countActiveForUserExcludingId(int $userId, int $excludeId): int;
|
||||
|
||||
public function countActive(): int;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Auth;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class EmailVerificationRepository
|
||||
class EmailVerificationRepository implements EmailVerificationRepositoryInterface
|
||||
{
|
||||
public function create(int $userId, string $codeHash, string $expiresAt): ?int
|
||||
{
|
||||
|
||||
18
lib/Repository/Auth/EmailVerificationRepositoryInterface.php
Normal file
18
lib/Repository/Auth/EmailVerificationRepositoryInterface.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Auth;
|
||||
|
||||
interface EmailVerificationRepositoryInterface
|
||||
{
|
||||
public function create(int $userId, string $codeHash, string $expiresAt): ?int;
|
||||
|
||||
public function invalidateForUser(int $userId): bool;
|
||||
|
||||
public function findActiveByUserId(int $userId): ?array;
|
||||
|
||||
public function findById(int $id): ?array;
|
||||
|
||||
public function incrementAttempts(int $id): bool;
|
||||
|
||||
public function markUsed(int $id): bool;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Auth;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class PasswordResetRepository
|
||||
class PasswordResetRepository implements PasswordResetRepositoryInterface
|
||||
{
|
||||
private function unwrapList($rows): array
|
||||
{
|
||||
|
||||
20
lib/Repository/Auth/PasswordResetRepositoryInterface.php
Normal file
20
lib/Repository/Auth/PasswordResetRepositoryInterface.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Auth;
|
||||
|
||||
interface PasswordResetRepositoryInterface
|
||||
{
|
||||
public function create(int $userId, string $codeHash, string $expiresAt): ?int;
|
||||
|
||||
public function invalidateForUser(int $userId): bool;
|
||||
|
||||
public function findActiveByUserId(int $userId): ?array;
|
||||
|
||||
public function findById(int $id): ?array;
|
||||
|
||||
public function incrementAttempts(int $id): bool;
|
||||
|
||||
public function markUsed(int $id): bool;
|
||||
|
||||
public function listByUserId(int $userId, int $limit = 20): array;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Auth;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class RememberTokenRepository
|
||||
class RememberTokenRepository implements RememberTokenRepositoryInterface
|
||||
{
|
||||
private function unwrapList($rows): array
|
||||
{
|
||||
|
||||
22
lib/Repository/Auth/RememberTokenRepositoryInterface.php
Normal file
22
lib/Repository/Auth/RememberTokenRepositoryInterface.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Auth;
|
||||
|
||||
interface RememberTokenRepositoryInterface
|
||||
{
|
||||
public function create(int $userId, string $selector, string $tokenHash, string $expiresAt): ?int;
|
||||
|
||||
public function findBySelector(string $selector): ?array;
|
||||
|
||||
public function updateToken(int $id, string $tokenHash, string $expiresAt): bool;
|
||||
|
||||
public function expireAllByAdmin(): int;
|
||||
|
||||
public function deleteById(int $id): bool;
|
||||
|
||||
public function deleteByUserId(int $userId): bool;
|
||||
|
||||
public function listByUserId(int $userId, int $limit = 20): array;
|
||||
|
||||
public function countActive(): int;
|
||||
}
|
||||
Reference in New Issue
Block a user