Laravel Passport calls for oauth_access_tokens every time I get User from request or Auth facade

Viewed 583

I have strange Passport behavior: I have non protected (public) endpoint in my API for example: GET: mysite.com/posts (no auth middleware here). This endpoint can be called with Authorization header (with bearer token). While I am handling request I check few times if there is loggedIn User with code: Auth::user() or $request->user() Every call produce SQL querie: select * from oauth_access_tokens where id = fwefwe435 limit 1 So I have 100500 duplicated queries and this is a problem. Can I somehow reduce this amount?

I've tried to use $request->setUserResolver() but no affect.

Ugly hack - just to cache queries from Laravel\Passport\TokenRepository

0 Answers
Related