+ */
+ public function getSubscriptions(): Collection
+ {
+ return $this->subscriptions;
+ }
+
+ public function addSubscription(Subscriptions $subscription): static
+ {
+ if (!$this->subscriptions->contains($subscription)) {
+ $this->subscriptions->add($subscription);
+ $subscription->setUsers($this);
+ }
+
+ return $this;
+ }
+
+ public function removeSubscription(Subscriptions $subscription): static
+ {
+ if ($this->subscriptions->removeElement($subscription)) {
+ // set the owning side to null (unless already changed)
+ if ($subscription->getUsers() === $this) {
+ $subscription->setUsers(null);
+ }
+ }
+
+ return $this;
+ }
}
diff --git a/src/Repository/AccessTokenRepository.php b/src/Repository/AccessTokenRepository.php
index f5a9529..6ac6134 100644
--- a/src/Repository/AccessTokenRepository.php
+++ b/src/Repository/AccessTokenRepository.php
@@ -10,9 +10,9 @@ use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
final class AccessTokenRepository implements AccessTokenRepositoryInterface
{
- private BaseAccessTokenRepository $baseAccessTokenRepository;
+ private AccessTokenRepositoryInterface $baseAccessTokenRepository;
- public function __construct(BaseAccessTokenRepository $baseAccessTokenRepository)
+ public function __construct(AccessTokenRepositoryInterface $baseAccessTokenRepository)
{
$this->baseAccessTokenRepository = $baseAccessTokenRepository;
}
diff --git a/src/Service/AccessTokenService.php b/src/Service/AccessTokenService.php
index dfafaef..f557c32 100644
--- a/src/Service/AccessTokenService.php
+++ b/src/Service/AccessTokenService.php
@@ -2,14 +2,37 @@
namespace App\Service;
-use App\Repository\UsersOrganizationsRepository;
+use Doctrine\ORM\EntityManagerInterface;
+use League\Bundle\OAuth2ServerBundle\Model\AccessToken;
+use Symfony\Component\Security\Core\User\UserInterface;
class AccessTokenService
{
- public function __construct()
+ private EntityManagerInterface $entityManager;
+
+ public function __construct(EntityManagerInterface $entityManager)
{
+ $this->entityManager = $entityManager;
+ }
+
+ public function revokeTokens(String $userIdentifier): void {
+ $accessTokens = $this->entityManager->getRepository(AccessToken::class)->findBy(['userIdentifier' => $userIdentifier, 'revoked' => false]);
+ foreach($accessTokens as $accessToken) {
+ $accessToken->revoke();
+ $this->entityManager->persist($accessToken);
+ $this->entityManager->flush();
+ }
+ }
+
+ public function getUserFromToken(string $token)
+ {
+ $data = json_decode(base64_decode(strtr($token, '-_', '+/')), true);
+ if (isset($data['user_identifier'])) {
+ return $data['user_identifier'];
+ }
+ return null;
}
diff --git a/symfony.lock b/symfony.lock
index 5996d0f..0993096 100644
--- a/symfony.lock
+++ b/symfony.lock
@@ -1,4 +1,13 @@
{
+ "doctrine/deprecations": {
+ "version": "1.1",
+ "recipe": {
+ "repo": "github.com/symfony/recipes",
+ "branch": "main",
+ "version": "1.0",
+ "ref": "87424683adc81d7dc305eefec1fced883084aab9"
+ }
+ },
"doctrine/doctrine-bundle": {
"version": "2.14",
"recipe": {
@@ -181,6 +190,18 @@
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
}
},
+ "symfony/mercure-bundle": {
+ "version": "0.3",
+ "recipe": {
+ "repo": "github.com/symfony/recipes",
+ "branch": "main",
+ "version": "0.3",
+ "ref": "528285147494380298f8f991ee8c47abebaf79db"
+ },
+ "files": [
+ "config/packages/mercure.yaml"
+ ]
+ },
"symfony/messenger": {
"version": "7.2",
"recipe": {
diff --git a/templates/base.html.twig b/templates/base.html.twig
index d9ae5f6..02bdcf0 100644
--- a/templates/base.html.twig
+++ b/templates/base.html.twig
@@ -16,6 +16,21 @@
{% block javascripts %}
{% block importmap %}{{ importmap('app') }}{% endblock %}
+
{% endblock %}
@@ -23,7 +38,7 @@
{{ include('elements/navbar.html.twig')}}
{% block body %}
-
+
{% endblock %}
diff --git a/templates/elements/navbar.html.twig b/templates/elements/navbar.html.twig
index 0ffaf77..cf7bd22 100644
--- a/templates/elements/navbar.html.twig
+++ b/templates/elements/navbar.html.twig
@@ -72,10 +72,10 @@
#}
-
- {{ ux_icon('material-symbols:logout', {height: '20px', width: '20px'}) }}
- Deconnexion
-
+{# #}
+{# {{ ux_icon('material-symbols:logout', {height: '20px', width: '20px'}) }} #}
+{# Deconnexion#}
+{# #}
diff --git a/templates/index/index.html.twig b/templates/index/index.html.twig
index 05f5194..54c44d4 100644
--- a/templates/index/index.html.twig
+++ b/templates/index/index.html.twig
@@ -4,9 +4,9 @@
{% block body %}
- {% if app.user %}
-
- You are logged in as {{ app.user.userIdentifier }},
Logout
-
- {% endif %}
+{# {% if app.user %}#}
+{# #}
+{# You are logged in as {{ app.user.userIdentifier }},
Logout#}
+{#
#}
+{# {% endif %}#}
{% endblock %}