Closed
Description
Passport Version
13.0.4
Laravel Version
12.x
PHP Version
8.4
Database Driver & Version
No response
Description
I have a simple LogoutFeatureTest that checks if the token is revoked. After upgrading Passport to latest version of 13.x, I started getting Undefined property: Laravel\Passport\AccessToken::$oauth_access_token_id
The documentation shows the following to revoke all tokens but even that fails with the same error message
// Revoke all of the user's tokens...
User::find($userId)->tokens()->each(function (Token $token) {
$token->revoke();
$token->refreshToken?->revoke();
});
Steps To Reproduce
A Simple LogoutFeatureTest:
class LogoutFeatureTest extends TestCase
{
use RefreshDatabase;
protected User $user;
protected function setUp(): void
{
parent::setUp();
$this->user = User::factory()->create([
'is_confirmed' => true,
]);
}
#[\PHPUnit\Framework\Attributes\Group('profile')]
#[\PHPUnit\Framework\Attributes\Group('functional')]
public function test_logout(): void
{
Passport::actingAs($this->user);
$this->post(route('api-v1::profile.logout'))
->assertSuccessful();
$this->assertTrue($this->user->token()->revoked);
}
}
RevokeTokenJob to be dispatched on LogoutController
class RevokeTokenJob
{
public function handle(Guard $auth): void
{
$auth->user()->token()->revoke();
}
}
Expected:
Test passes
Actual:
testing.ERROR: Undefined property: Laravel\Passport\AccessToken::$oauth_access_token_id {"userId":22,"exception":"[object] (ErrorException(code: 0): Undefined property: Laravel\\Passport\\AccessToken::$oauth_access_token_id at /var/www/vendor/laravel/passport/src/AccessToken.php:95)
[stacktrace]
#0 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 /var/www/vendor/laravel/passport/src/AccessToken.php(95): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->{closure:Illuminate\\Foundation\\Bootstrap\\HandleExceptions::forwardsTo():255}()
#2 /var/www/vendor/laravel/passport/src/AccessToken.php(145): Laravel\\Passport\\AccessToken->getToken()
#3 /var/www/vendor/laravel/passport/src/AccessToken.php(87): Laravel\\Passport\\AccessToken->__get()
#4 /var/www/app/Domains/Profile/Jobs/RevokeTokenJob.php(13): Laravel\\Passport\\AccessToken->revoke()
P.S: Last assertion may be faulty but it fails on post request assertion
Metadata
Metadata
Assignees
Labels
No labels