title: how to check if user is authenticated with passport (get user from token using laravel-passport)
body: <p>I am using Passport to log in users to a Laravel API endpoint, users get authenticated using their social accounts (google, facebook) using laravel-socialite package.</p>
  
  <p>the workflow of logging users in and out works perfectly (generating tokens...Etc). The problem is I have a controller that should return data based on whether there is a user logged in or not.</p>
  
  <p>I do intercept the Bearer token from the HTTP request but I couldn't get the user using the token (I would use DB facade to select the user based on the token but I am actually looking whether there is a more clean way already implemented in Passport) </p>
  
  <p>I also don't want to use auth:api middleware as the controller should work and return data even if no user is logged in.</p>
  
  <p>this is the api route:</p>
  
  <pre class="lang-php prettyprint-override"><code>Route::get("/articles/{tag?}", "ArticleController@get_tagged");
  </code></pre>
  
  <p>this is the logic I want the controller to have</p>
  
  <pre class="lang-php prettyprint-override"><code>public function get_tagged($tag = "", Request $request)
  {
      if ($request-&gt;header("Authorization"))
          // return data related to the user
      else
          // return general data
  }
  </code></pre>