i really need help with one little thing I try to do. I try to use concurrent personal_access_tokens in my laravel / Vue setup for one user. Everything is working fine, all but one thing where I want to delete one token by it's id when the user is logging out. With the login of one user, I create a personal_access_token for them. With the logout this specific access_token should be deleted.
Right now in my logout method, I delete all tokens. That works fine, but when deleting one specific token (which should work) I always get errors that this method doesn't exist:
public function logout(Request $request){
Auth::guard('web')->logout();
// First try: auth()->user()->currentAccessToken()->delete();
// Second try: $request->user()->token()->revoke();
auth()->user()->tokens()->delete();
}
The error:
LOG.error: Call to undefined method Laravel\Sanctum\TransientToken::delete() {"userId":18,"exception":{}}
api.php
Route::group(['middleware' => 'auth:sanctum'], function () {
Route::post('/logout', [AuthController::class, 'logout']);
});
I tried following things from:
https://laracasts.com/discuss/channels/laravel/passport-how-can-i-manually-revoke-access-token (passport) https://laracasts.com/discuss/channels/laravel/deleting-users-passport-token-on-logout https://divinglaravel.com/authentication-and-laravel-airlock https://laracasts.com/discuss/channels/laravel/spa-and-mobile-logout?page=1&replyId=698040
In all those threads the used methods should work but not for me. Do I overlook something?
I appreciate every help!