mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-27 17:15:02 +00:00
Get session from requestStack instead of injecting SessionInterface
This commit is contained in:
@@ -18,7 +18,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use TheNetworg\OAuth2\Client\Provider\Azure;
|
||||
use TheNetworg\OAuth2\Client\Token\AccessToken;
|
||||
|
||||
@@ -29,12 +29,12 @@ class OnBehalfOfUserTokenStorage
|
||||
{
|
||||
final public const MS_GRAPH_ACCESS_TOKEN = 'msgraph_access_token';
|
||||
|
||||
public function __construct(private readonly Azure $azure, private readonly SessionInterface $session) {}
|
||||
public function __construct(private readonly Azure $azure, private readonly RequestStack $requestStack) {}
|
||||
|
||||
public function getToken(): AccessToken
|
||||
{
|
||||
/** @var ?AccessToken $token */
|
||||
$token = $this->session->get(self::MS_GRAPH_ACCESS_TOKEN, null);
|
||||
$token = $this->requestStack->getSession()->get(self::MS_GRAPH_ACCESS_TOKEN, null);
|
||||
|
||||
if (null === $token) {
|
||||
throw new \LogicException('unexisting token');
|
||||
@@ -53,11 +53,11 @@ class OnBehalfOfUserTokenStorage
|
||||
|
||||
public function hasToken(): bool
|
||||
{
|
||||
return $this->session->has(self::MS_GRAPH_ACCESS_TOKEN);
|
||||
return $this->requestStack->getSession()->has(self::MS_GRAPH_ACCESS_TOKEN);
|
||||
}
|
||||
|
||||
public function setToken(AccessToken $token): void
|
||||
{
|
||||
$this->session->set(self::MS_GRAPH_ACCESS_TOKEN, $token);
|
||||
$this->requestStack->getSession()->set(self::MS_GRAPH_ACCESS_TOKEN, $token);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user