Files
accounts/common/components/OAuth2/Grants/CheckOfflineAccessScopeTrait.php
2025-01-09 01:23:41 +01:00

27 lines
812 B
PHP

<?php
declare(strict_types=1);
namespace common\components\OAuth2\Grants;
use common\components\OAuth2\Events\RequestedRefreshToken;
use common\components\OAuth2\Repositories\PublicScopeRepository;
use League\OAuth2\Server\EventEmitting\EventEmitter;
trait CheckOfflineAccessScopeTrait {
abstract public function getEmitter(): EventEmitter;
/**
* @param \League\OAuth2\Server\Entities\ScopeEntityInterface[] $scopes
*/
protected function checkOfflineAccessScope(array $scopes = []): void {
foreach ($scopes as $i => $scope) {
if ($scope->getIdentifier() === PublicScopeRepository::OFFLINE_ACCESS) {
unset($scopes[$i]);
$this->getEmitter()->emit(new RequestedRefreshToken('refresh_token_requested'));
}
}
}
}