Skip to content

Commit

Permalink
Hotfix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Syndesi committed Sep 2, 2023
1 parent 01f03ff commit d244564
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Changed
- Hotfix.

## 0.0.25 - 2023-08-31
### Changed
- **Note**: This release is broken.
### Added
- Add CI workflow to check for upstream Alpine updated.
- Add supervisord to combine all relevant logs and publish to docker logs.
Expand Down
17 changes: 10 additions & 7 deletions src/Controller/User/DeleteTokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace App\Controller\User;

use App\Exception\ClientNotFoundException;
use App\Exception\ClientUnauthorizedException;
use App\Factory\Exception\Client401UnauthorizedExceptionFactory;
use App\Factory\Exception\Client404NotFoundExceptionFactory;
use App\Response\NoContentResponse;
use App\Security\AuthProvider;
use App\Service\ElementManager;
use LogicException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
Expand All @@ -15,7 +16,9 @@ class DeleteTokenController extends AbstractController
{
public function __construct(
private ElementManager $elementManager,
private AuthProvider $authProvider
private AuthProvider $authProvider,
private Client401UnauthorizedExceptionFactory $client401UnauthorizedExceptionFactory,
private Client404NotFoundExceptionFactory $client404NotFoundExceptionFactory
) {
}

Expand All @@ -29,21 +32,21 @@ public function deleteToken(): Response
$userUuid = $this->authProvider->getUserUuid();

if (!$userUuid) {
throw new ClientUnauthorizedException();
throw $this->client401UnauthorizedExceptionFactory->createFromTemplate();
}

if ($this->authProvider->isAnonymous()) {
throw new ClientUnauthorizedException();
throw $this->client401UnauthorizedExceptionFactory->createFromTemplate();
}

$tokenUuid = $this->authProvider->getTokenUuid();
if (null === $tokenUuid) {
throw new \LogicException('Token must be provided.');
throw new LogicException('Token must be provided.');
}

$element = $this->elementManager->getElement($tokenUuid);
if (null === $element) {
throw new ClientNotFoundException();
throw $this->client404NotFoundExceptionFactory->createFromTemplate();
}
$this->elementManager->delete($element);
$this->elementManager->flush();
Expand Down
9 changes: 5 additions & 4 deletions src/Controller/User/GetTokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Controller\User;

use App\Exception\ClientUnauthorizedException;
use App\Factory\Exception\Client401UnauthorizedExceptionFactory;
use App\Security\AuthProvider;
use App\Service\CollectionService;
use Laudis\Neo4j\Databags\Statement;
Expand All @@ -17,7 +17,8 @@ class GetTokenController extends AbstractController
public function __construct(
private CypherEntityManager $cypherEntityManager,
private AuthProvider $authProvider,
private CollectionService $collectionService
private CollectionService $collectionService,
private Client401UnauthorizedExceptionFactory $client401UnauthorizedExceptionFactory
) {
}

Expand All @@ -31,11 +32,11 @@ public function getToken(): Response
$userUuid = $this->authProvider->getUserUuid();

if (!$userUuid) {
throw new ClientUnauthorizedException();
throw $this->client401UnauthorizedExceptionFactory->createFromTemplate();
}

if ($this->authProvider->isAnonymous()) {
throw new ClientUnauthorizedException();
throw $this->client401UnauthorizedExceptionFactory->createFromTemplate();
}

$cypherClient = $this->cypherEntityManager->getClient();
Expand Down

0 comments on commit d244564

Please sign in to comment.