Skip to content

Commit 587aa14

Browse files
allow overriding the AccessToken class (#1638)
1 parent d95c095 commit 587aa14

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/Bridge/AccessTokenRepository.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use DateTime;
66
use Illuminate\Contracts\Events\Dispatcher;
77
use Laravel\Passport\Events\AccessTokenCreated;
8+
use Laravel\Passport\Passport;
89
use Laravel\Passport\TokenRepository;
910
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
1011
use League\OAuth2\Server\Entities\ClientEntityInterface;
@@ -46,7 +47,7 @@ public function __construct(TokenRepository $tokenRepository, Dispatcher $events
4647
*/
4748
public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, $userIdentifier = null)
4849
{
49-
return new AccessToken($userIdentifier, $scopes, $clientEntity);
50+
return new Passport::$accessTokenEntity($userIdentifier, $scopes, $clientEntity);
5051
}
5152

5253
/**

src/Passport.php

+18
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ class Passport
7979
*/
8080
public static $keyPath;
8181

82+
/**
83+
* The access token entity class name.
84+
*
85+
* @var string
86+
*/
87+
public static $accessTokenEntity = 'Laravel\Passport\Bridge\AccessToken';
88+
8289
/**
8390
* The auth code model class name.
8491
*
@@ -432,6 +439,17 @@ public static function keyPath($file)
432439
: storage_path($file);
433440
}
434441

442+
/**
443+
* Set the access token entity class name.
444+
*
445+
* @param string $accessTokenEntity
446+
* @return void
447+
*/
448+
public static function useAccessTokenEntity($accessTokenEntity)
449+
{
450+
static::$accessTokenEntity = $accessTokenEntity;
451+
}
452+
435453
/**
436454
* Set the auth code model class name.
437455
*

0 commit comments

Comments
 (0)