diff options
| author | Daniel Weipert <git@mail.dweipert.de> | 2026-04-10 13:37:26 +0200 |
|---|---|---|
| committer | Daniel Weipert <git@mail.dweipert.de> | 2026-04-10 13:41:14 +0200 |
| commit | 99006cd6370f0502693f3fa9e3c20c83c02b364f (patch) | |
| tree | 911c34cd93444f37f4781208020853bae9c42b7a /src/Models/User.php | |
| parent | 6929089fea7cf79ae5ca9e05486ba33b0e5b216d (diff) | |
switch routing to attributes
Diffstat (limited to 'src/Models/User.php')
| -rw-r--r-- | src/Models/User.php | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Models/User.php b/src/Models/User.php index b8aad62..b24afaf 100644 --- a/src/Models/User.php +++ b/src/Models/User.php @@ -22,7 +22,7 @@ class User implements ConnectsToDatabase { return new self( $row["id"], - $row["name"], + $row["name"] ?? "", ); } @@ -82,6 +82,11 @@ class User implements ConnectsToDatabase public static function authenticateWithRequest(Request $request): self { $accessToken = str_replace("Bearer ", "", $request->headers->get("authorization") ?: ""); + + if (empty($accessToken)) { + throw new AppException(ErrorCode::UNAUTHORIZED, "Missing access token", Response::HTTP_UNAUTHORIZED); + } + $user = self::fetchWithAccessToken($accessToken); if (empty($user)) { |
