diff options
| author | Daniel Weipert <git@mail.dweipert.de> | 2026-04-14 16:33:04 +0200 |
|---|---|---|
| committer | Daniel Weipert <git@mail.dweipert.de> | 2026-04-14 16:33:04 +0200 |
| commit | f3202403339e94f0186b9ff19e83c7a32fdad198 (patch) | |
| tree | c3310b1f456f12a7a92f51948d9c8caf94f11032 /src/Models/User.php | |
| parent | 875b9ece501de5937993c41a83c44f8ea59897d0 (diff) | |
implementing against Cinny and iamb some more
Diffstat (limited to 'src/Models/User.php')
| -rw-r--r-- | src/Models/User.php | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/Models/User.php b/src/Models/User.php index 4c016ad..a30bee0 100644 --- a/src/Models/User.php +++ b/src/Models/User.php @@ -12,6 +12,8 @@ use Symfony\Component\HttpFoundation\Response; class User implements ConnectsToDatabase { + private string $deviceId; + public function __construct( private string $id, private string $name, @@ -62,7 +64,7 @@ class User implements ConnectsToDatabase public static function fetchWithAccessToken(string $accessToken): ?self { $row = Database::getInstance()->query(<<<SQL - select users.* from users left join tokens on tokens.user_id = users.id where tokens.access_token=:access_token + select users.*, tokens.device_id from users left join tokens on tokens.user_id = users.id where tokens.access_token=:access_token SQL, [ "access_token" => $accessToken, ])->fetch(); @@ -71,7 +73,10 @@ class User implements ConnectsToDatabase return null; } - return self::fromDatabase($row); + $user = self::fromDatabase($row); + $user->setDeviceId($row["device_id"]); + + return $user; } public static function new(string $id, string $name): self @@ -137,9 +142,25 @@ class User implements ConnectsToDatabase return $this->name; } + public function setDeviceId(string $id): void + { + $this->deviceId = $id; + } + + public function getDeviceId(): string + { + return $this->deviceId; + } + public function fetchDevice(string $id): ?Device { - return Device::fetch($id, $this->id); + $device = Device::fetch($id, $this->id); + + if ($device) { + $this->setDeviceId($device->getId()); + } + + return $device; } /** |
