-
Notifications
You must be signed in to change notification settings - Fork 119
Description
네, 요청하신 틀에 맞춰 php-open-source-saver/jwt-auth 패키지에서
Subject of the issue
Auth::guard('jwt')->id() returns
Your environment:
| Q | A |
|---|---|
| Bug? | yes |
| New Feature? | no |
| Framework | Laravel |
| Framework version | 11.46.0 |
| Package version | 2.8.2 |
| PHP version | 8.3.26 |
Steps to reproduce
- Ensure your database primary key for the
userstable is an$\text{INTEGER}$ (standard Laravel setup). - Log in a user to generate a
$\text{JWT}$ . - Access the authenticated user's
$\text{ID}$ using the$\text{jwt}$ guard.
$user_id = Auth::guard('jwt')->id();
// Or using the helper function
$user_id_helper = auth('jwt')->id();- Check the data type of the returned
$\text{ID}$ .
// Check the type of the returned ID
dd([
'ID from auth()->id()' => auth()->id(),
'ID from auth(\'jwt\')->id()' => auth('jwt')->id(),
'Type of JWT ID' => gettype(auth('jwt')->id()),
'ID from Auth::id()' => Auth::id(),
'ID from Auth::guard(\'jwt\')->id()' => Auth::guard('jwt')->id(),
'Type of JWT Guard ID' => gettype(Auth::guard('jwt')->id()),
]);Expected behaviour
The
Expected output for type check:
...
'Type of JWT ID' => 'integer',
'Type of JWT Guard ID' => 'integer',(assuming the default guard returns $\text{integer}$)
Actual behaviour
The
Actual output from the
array:6 [
"ID from auth()->id()" => 1779851
"ID from auth('jwt')->id()" => "1779851"
"Type of JWT ID" => "string" // <-- ISSUE
"ID from Auth::id()" => 1779851
"ID from Auth::guard('jwt')->id()" => "1779851"
"Type of JWT Guard ID" => "string" // <-- ISSUE
]This requires explicit type casting ((int)) in application code when comparing the