From bd11271621bd3759cfd194ed0119c0dc28155fd0 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 5 Mar 2026 14:57:28 +0100 Subject: update --- src/Models/Tokens.php | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/Models/Tokens.php') diff --git a/src/Models/Tokens.php b/src/Models/Tokens.php index 4ad8e1d..ee912fb 100644 --- a/src/Models/Tokens.php +++ b/src/Models/Tokens.php @@ -37,9 +37,9 @@ class Tokens implements ConnectsToDatabase $isExpiredSql = ""; if ($isExpired) { - $isExpiredSql = "and expires_at <= current_timestamp"; + #$isExpiredSql = "and expires_at <= current_timestamp"; } else { - $isExpiredSql = "and expires_at > current_timestamp"; + #$isExpiredSql = "and expires_at > current_timestamp"; } $row = []; @@ -78,6 +78,26 @@ class Tokens implements ConnectsToDatabase public static function fetchAll(): array {} + public static function fetchWithAccessToken(string $accessToken): ?self + { + $row = Database::getInstance()->query( + << $accessToken, + ] + )->fetch(); + + if (empty($row)) { + return null; + } + + return self::fromDatabase($row); + } + public static function fetchWithRefreshToken(string $refreshToken): ?self { $row = Database::getInstance()->query( @@ -140,6 +160,11 @@ class Tokens implements ConnectsToDatabase ); } + public function isExpired(): bool + { + return $this->expiresAt->format("U.v") <= time(); + } + public function getAccessToken(): string { return $this->accessToken; -- cgit v1.2.3