But I can not do it cause my routes are same for all users (including not logged in). But I need to check if user is logged (if JWT token is valid) in in controller. I am not sure if auth()->chcek() is enough in the case of API token check. Is there neccessary to ad some other logic or not?
@tisuchi Thanks but the article is based on router middleware check or on controller::__construct() middleware check. But I need to make auth check on controller methods level. It schould check inside the method and do not throw auth exception but only boolean value.
@Čamo I do not recommend it, since it's easy for you or someone else on the team to forget to add that check for an endpoint. And you end up with an unprotected route.
So the problem is that Laravel executes middlewares after __construct() method. I thought middlewares runs first or imediatelly how they are called from constroller.