Issue with Token Revocation for Custom Model in Laravel Passport
I've created a portal_users table with its corresponding model PortalUser in Laravel. I’ve added the Authenticatable trait to this model and set up a custom guard and provider as follows:
//guard
'portal' => [
'driver' => 'passport',
'provider' => 'portal_users'
]
//provider
'portal_users' => [
'driver' => 'eloquent',
'model' => App\Models\PortalUser::class
],
I can create personal access tokens for PortalUser using Passport, but I’m encountering an issue when revoking these tokens. Specifically, when I attempt to revoke tokens using the PortalUser model, it inadvertently revokes tokens associated with the User model that have the same ID.
Here’s how I’m currently revoking tokens:
$user = PortalUser::find(1);
foreach($user->tokens as $token){
$token->revoke();
}
and my tokens are stored in oauth_access_tokens table.
How can I ensure that only tokens for PortalUser are revoked and not tokens associated with other models?
Please or to participate in this conversation.