logout lumen passport code example

Example 1: logout lumen passport

public function logout(Request $request) {
    $token = $request->bearerToken();
    if ($token) {
        $id = (new Parser())->parse($token)->getHeader('jti');
        DB::table('oauth_access_tokens')->where('id', '=', $id)->update(['revoked' => 1]);
    }
 
    return [
        'status' => 'success',
        'message' => 'Logout successfully.'
    ];
}

Example 2: logout lumen passport

public function logoutApi()
{ 
    if (Auth::check()) {
       Auth::user()->AauthAcessToken()->delete();
    }
}

Tags:

Misc Example