DEV Community

techdurjoy
techdurjoy

Posted on

2 1

How to Logout User from API with Laravel Passport

How to Logout User from API with Laravel Passport. How to Logout User from API with Laravel Passport. How to Logout User from API with Laravel Passport. How to Logout User from API with Laravel Passport. How to Logout User from API with Laravel Passport. How to Logout User from API with Laravel Passport.How to Logout User from API with Laravel Passport.
How to Logout User from API with Laravel Passport. How to Logout User from API with Laravel Passport. How to Logout User from API with Laravel Passport. How to Logout User from API with Laravel Passport. How to Logout User from API with Laravel Passport. How to Logout User from API with Laravel Passport.How to Logout User from API with Laravel Passport.

How to Logout User from API with Laravel Passport

Top comments (1)

Collapse
 
nandeshwar750 profile image
Nandeshwar Katenga
 use Laravel\Passport\RefreshToken;
   public function logout()
   {
       $user = Auth::user();
       $user->token()->revoke();
       RefreshToken::where('access_token_id', $user->token()->id)->delete();

       return response()->json(['message' => 'User logged out successfully']);
   }
Enter fullscreen mode Exit fullscreen mode

Read More here.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more