title: I need to log in to another user from my Admin account without a password
body: <p>I'm working on a feature that makes it possible for an admin/super-user to select an account from a user list, and then logout from the admin account and immediately log in as the selected user. This must happen without the admin knowing the user's password.</p>
  
  <p>I am using Laravel with Laravel passport alongside Vue, when a user logs in he receives a token with which he can access his role's pages.</p>
  
  <p>I saw that it was possible with <code>Auth::loginById</code> but this does not work with Laravel Passport.</p>
  
  <p>In my <code>AdminController</code> I have the following function that obviously doesn't work yet.</p>
  
  <pre class="lang-php prettyprint-override"><code>public function shadowLogin($id)
      {
          $user = User::find($id)-&gt;first();
          $credentials = [
              'username' =&gt; $user-&gt;username,
              'password' =&gt; ''
          ];
  
          if (auth()-&gt;attempt($username)) {
              $hierarchy = Hierarchy::where('id', auth()-&gt;user()-&gt;hierarchy_id)-&gt;first();
  
              $token = auth()-&gt;user()-&gt;createToken('tokenkey', [$hierarchy-&gt;hierarchy_name])-&gt;accessToken;
  
              return response()-&gt;json(['data' =&gt; auth()-&gt;user(), 'token' =&gt; $token], 200);
          }
      }
  </code></pre>
  
  <p>I expect to eventually be able to 'switch' the currently stored user in vue to 'switch' to the selected User account, redirecting to the home page and being logged in.</p>