Open podluzhnyi opened 7 years ago
Same here
@podluzhnyi @pedrogaldino gonna check it right now
@pedrogaldino @pedrogaldino can you explain better where are you triggering this?
The Guard instance should be registered on the laravel and it's not instantiable with resolve since it needs some parameters.
the other guards, default ones are the same
@podluzhnyi @pedrogaldino @hernandev - did you guys ever find the cause of this? I'm experiencing this exact same issue on Laravel 5.6 / PHP 7.2.
Just came back from running some errands - took a fresh look at this, I think I figure out what @hernandev meant - this error went away in my code when I stopped trying to have the Guard
DI'd into my controller and instead used the Auth
facade.
Example:
// This won't even run - the DI will fail. This is adapted from the current README.md.
public function refreshToken(Guard $auth, Request $request)
{
$token = $auth->refresh();
return response()->json(compact('token'));
}
Instead, running the following works:
public function refreshToken(Request $request)
{
$token = \Auth::refresh();
return response()->json(compact('token'));
}
Once I switched to the latter method, all my tests passed. As such, we probably want to update the README. I'll submit a PR.
I'm rather new to laravel but this looks kind of fishy to me:
Is there any reason a fresh guard is returned and not $guard
?
@Anticom I have already fixed this in PR https://github.com/codecasts/laravel-jwt/pull/45. @hernandev returning a new instance of the guard resulted in the Auth events not being fired (bug), I fixed that in my PR, but now because Laravel 5.7 changed the events constructor, the package need to be updated for 5.7 also.
This means the next release of the package will be for >= 5.7 only
After installation strictly according to the instructions, I have a exception:
Unresolvable dependency resolving [Parameter #0 [ $app ]] in class Codecasts\Auth\JWT\Auth\Guard in Container.php (line 910)
Laravel 5.4.28
I did: