Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
hafezdivandari committed Dec 10, 2024
1 parent 67fde5f commit 1e79f26
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Bridge/PersonalAccessGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Laravel\Passport\Passport;
use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Grant\AbstractGrant;
use League\OAuth2\Server\RequestAccessTokenEvent;
use League\OAuth2\Server\RequestEvent;
use League\OAuth2\Server\ResponseTypes\ResponseTypeInterface;
use Psr\Http\Message\ServerRequestInterface;

Expand Down Expand Up @@ -48,6 +50,10 @@ public function respondToAccessTokenRequest(
$scopes
);

// Send event to emitter
$this->getEmitter()->emit(new RequestAccessTokenEvent(RequestEvent::ACCESS_TOKEN_ISSUED, $request, $accessToken));

// Persist access token's name
Passport::token()->newQuery()->whereKey($accessToken->getIdentifier())->update([
'name' => $this->getRequestParameter('name', $request),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Middleware/EnsureClientIsResourceOwner.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class EnsureClientIsResourceOwner extends ValidateToken
*/
protected function validate(AccessToken $token, string ...$params): void
{
if ($token->oauth_user_id !== $token->oauth_client_id) {
if (! is_null($token->oauth_user_id) && $token->oauth_user_id !== $token->oauth_client_id) {
throw new AuthenticationException;
}

Expand Down

0 comments on commit 1e79f26

Please sign in to comment.