Skip to content

Commit

Permalink
Cast username to string
Browse files Browse the repository at this point in the history
  • Loading branch information
stayallive committed Apr 18, 2024
1 parent 9bb3dbf commit 85f57a0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Sentry/Laravel/EventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,14 @@ private function configureUserScopeFromModel($authUser): void

// If the user is a Laravel Eloquent model we try to extract some common fields from it
if ($authUser instanceof Model) {
$username = $authUser->getAttribute('username');

$userData = [
'id' => $authUser instanceof Authenticatable
? $authUser->getAuthIdentifier()
: $authUser->getKey(),
'email' => $authUser->getAttribute('email') ?? $authUser->getAttribute('mail'),
'username' => $authUser->getAttribute('username'),
'username' => $username === null ? $username : (string)$username,
];
}

Expand Down

0 comments on commit 85f57a0

Please sign in to comment.