mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-22 15:13:59 -06:00
Moved AuthenticationException to Rest module
This commit is contained in:
parent
7efb3b3a86
commit
8fc88171ee
@ -40,7 +40,8 @@
|
||||
"Acelaya\\UrlShortener\\": "src",
|
||||
"Shlinkio\\Shlink\\CLI\\": "module/CLI/src",
|
||||
"Shlinkio\\Shlink\\Rest\\": "module/Rest/src",
|
||||
"Shlinkio\\Shlink\\Core\\": "module/Core/src"
|
||||
"Shlinkio\\Shlink\\Core\\": "module/Core/src",
|
||||
"Shlinkio\\Shlink\\Common\\": "module/Common/src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
@ -48,7 +49,8 @@
|
||||
"AcelayaTest\\UrlShortener\\": "tests",
|
||||
"ShlinkioTest\\Shlink\\CLI\\": "module/CLI/test",
|
||||
"ShlinkioTest\\Shlink\\Rest\\": "module/Rest/test",
|
||||
"ShlinkioTest\\Shlink\\Core\\": "module/Core/test"
|
||||
"ShlinkioTest\\Shlink\\Core\\": "module/Core/test",
|
||||
"ShlinkioTest\\Shlink\\Common\\": "module/Common/test"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace Shlinkio\Shlink\Rest\Action;
|
||||
|
||||
use Acelaya\UrlShortener\Exception\AuthenticationException;
|
||||
use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Shlinkio\Shlink\Rest\Exception\AuthenticationException;
|
||||
use Shlinkio\Shlink\Rest\Service\RestTokenService;
|
||||
use Shlinkio\Shlink\Rest\Service\RestTokenServiceInterface;
|
||||
use Shlinkio\Shlink\Rest\Util\RestUtils;
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
namespace Acelaya\UrlShortener\Exception;
|
||||
namespace Shlinkio\Shlink\Rest\Exception;
|
||||
|
||||
use Acelaya\UrlShortener\Exception\ExceptionInterface;
|
||||
|
||||
class AuthenticationException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
@ -2,10 +2,10 @@
|
||||
namespace Shlinkio\Shlink\Rest\Service;
|
||||
|
||||
use Acelaya\UrlShortener\Entity\RestToken;
|
||||
use Acelaya\UrlShortener\Exception\AuthenticationException;
|
||||
use Acelaya\UrlShortener\Exception\InvalidArgumentException;
|
||||
use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Shlinkio\Shlink\Rest\Exception\AuthenticationException;
|
||||
|
||||
class RestTokenService implements RestTokenServiceInterface
|
||||
{
|
||||
|
@ -2,8 +2,8 @@
|
||||
namespace Shlinkio\Shlink\Rest\Service;
|
||||
|
||||
use Acelaya\UrlShortener\Entity\RestToken;
|
||||
use Acelaya\UrlShortener\Exception\AuthenticationException;
|
||||
use Acelaya\UrlShortener\Exception\InvalidArgumentException;
|
||||
use Shlinkio\Shlink\Rest\Exception\AuthenticationException;
|
||||
|
||||
interface RestTokenServiceInterface
|
||||
{
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
namespace Shlinkio\Shlink\Rest\Util;
|
||||
|
||||
use Acelaya\UrlShortener\Exception;
|
||||
use Acelaya\UrlShortener\Exception as Core;
|
||||
use Shlinkio\Shlink\Rest\Exception as Rest;
|
||||
|
||||
class RestUtils
|
||||
{
|
||||
@ -12,16 +13,16 @@ class RestUtils
|
||||
const INVALID_AUTH_TOKEN_ERROR = 'INVALID_AUTH_TOKEN_ERROR';
|
||||
const UNKNOWN_ERROR = 'UNKNOWN_ERROR';
|
||||
|
||||
public static function getRestErrorCodeFromException(Exception\ExceptionInterface $e)
|
||||
public static function getRestErrorCodeFromException(Core\ExceptionInterface $e)
|
||||
{
|
||||
switch (true) {
|
||||
case $e instanceof Exception\InvalidShortCodeException:
|
||||
case $e instanceof Core\InvalidShortCodeException:
|
||||
return self::INVALID_SHORTCODE_ERROR;
|
||||
case $e instanceof Exception\InvalidUrlException:
|
||||
case $e instanceof Core\InvalidUrlException:
|
||||
return self::INVALID_URL_ERROR;
|
||||
case $e instanceof Exception\InvalidArgumentException:
|
||||
case $e instanceof Core\InvalidArgumentException:
|
||||
return self::INVALID_ARGUMENT_ERROR;
|
||||
case $e instanceof Exception\AuthenticationException:
|
||||
case $e instanceof Rest\AuthenticationException:
|
||||
return self::INVALID_CREDENTIALS_ERROR;
|
||||
default:
|
||||
return self::UNKNOWN_ERROR;
|
||||
|
Loading…
Reference in New Issue
Block a user