laravel / passport

Laravel Passport provides OAuth2 server support to Laravel.
https://laravel.com/docs/passport
MIT License
3.28k stars 776 forks source link

Impossible to logout/flush session via api call #1666

Closed hamid-taei closed 1 year ago

hamid-taei commented 1 year ago

Passport Version

10.4

Laravel Version

8.75

PHP Version

7.4

Database Driver & Version

MySql 8

Description

Passport uses a web login form to authenticate API users. I couldn't find a way to log out from the web via API call which cause difficulties during development and testing.

Steps To Reproduce

public function logout(Request $request)
{
    $tokens =  Auth::user()->tokens()->pluck('id');
    Token::whereIn('id', $tokens)
        ->update(['revoked'=> true]);

    RefreshToken::whereIn('access_token_id', $tokens)->update(['revoked' => true]);
    auth('web')->logout(); // Can not log out from web here. 
        $data['success'] = true;
        $data['message'] = "Logged out successfully.";
        return response()->json($data, '200');
}
driesvints commented 1 year ago

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.