-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when using the auth()->tokenById($id) function. #2253
Comments
I encountered a similar issue with the Here’s how I modified the configuration: // In config/jwt.php
'ttl' => (int) env('JWT_TTL', 60), // Cast to int here This change ensures that the ttl value is always an integer, regardless of how it's specified in the environment variables. It might be helpful to include this type of casting within the library itself to prevent similar issues. Hope this helps! |
Subject of the issue
When using the tokenById function, the error Carbon\Carbon::rawAddUnit(): Argument #3 ($value) must be of type int|float, string given, called in /var/www/html/vendor /nesbot/carbon/src/Carbon/Traits/Units.php on line 356 is fired.
The problem occurred with the variable JWT_TTL which is arriving as a string instead of an integer when this function is called
/**
* Get the Expiration (exp) claim.
*
* @return int
*/
public function exp()
{
return Utils::now()->addMinutes($this->ttl)->getTimestamp();
}
This change resolved the issue in an alternative way:
$ttl = (int) $this->ttl;
return Utils::now()->addMinutes($ttl)->getTimestamp();
Your environment
Steps to reproduce
Perform a simple authentication using the auth()->tokenById($id) function.
The text was updated successfully, but these errors were encountered: