Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

pirmax's avatar

Laravel API / Passport - Change auth user

I use Laravel 5.7 with Passport and Vue component.

I have a Vue component with method to change Auth of user, this method call API by POST.

My API is protected by auth:api middleware.

The connexion to site is with PHP session. I don't want use JWT.

How I can change the account connected ?

public function switchAccount(Request $request, Team $team, User $user)
{
    Auth::guard('web')->login($user);
}
0 likes
0 replies

Please or to participate in this conversation.