You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not able to limit access to the /health endpoint using middleware. There's no way to retrieve the user making the request ($request->user() returns null). Am I missing something?
Not sure if it is possible to use middleware with parameters (e.g. role:admin)?
What is the issue?
/health
endpoint using middleware. There's no way to retrieve the user making the request ($request->user()
returnsnull
). Am I missing something?role:admin
)?Steps To Reproduce
Use existing middleware, e.g.:
or try with a custom one (try to dump the user) and visit the
/health
endpoint.As you can see I was redirected to the login page, but since I was already logged in, the app redirected me back to the home page.
Expected behaviour
If the user is authenticated, the user object should be accessible so I could make some additional authorization checks.
Additional context
Works fine when the
middleware
parameter is empty or contains a middleware which does not try to access the user object.Tested with Laravel 8.76.1.
The text was updated successfully, but these errors were encountered: