Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Exceptions/ForbiddenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use Throwable;

/**
* This exception should be thrown when the requesting user does not have rights to perform a specific action on a
* requested resource.
* This exception should be thrown when the requesting user doesn't have
* the permission to perform a specific action on a requested resource.
*/
class ForbiddenException extends AbstractException
{
Expand Down
12 changes: 6 additions & 6 deletions src/Exceptions/Interfaces/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ interface ExceptionInterface extends JsonSchemaErrorInterface
'title' => 'Resource Not Found',
];

const RESOURCE_HANDLED_BY_3RD_PARTY = [
'code' => '10014',
'title' => 'Resource Handled By 3rd Party',
];

const INVALID_JSON_SCHEMA = [
'code' => '10003',
'title' => 'Invalid JSON Schema',
Expand Down Expand Up @@ -82,6 +77,11 @@ interface ExceptionInterface extends JsonSchemaErrorInterface
'title' => 'Action not allowed.',
];

const RESOURCE_HANDLED_BY_3RD_PARTY = [
'code' => '10014',
'title' => 'Resource Handled By 3rd Party',
];

// External API related errors 13000 - 13999
const EXTERNAL_REQUEST_ERROR = [
'code' => '13001',
Expand Down Expand Up @@ -121,7 +121,7 @@ interface ExceptionInterface extends JsonSchemaErrorInterface

const AUTH_MISSING_SCOPE = [
'code' => '14004',
'title' => 'Access Token Is Invalid',
'title' => 'Missing scope in access token',
];

const AUTH_SERVER_EXCEPTION = [
Expand Down
8 changes: 6 additions & 2 deletions src/Exceptions/MissingScopeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
use Symfony\Component\HttpFoundation\Response;
use Throwable;

/**
* This exception should be thrown when the requesting user
* doesn't have the required scopes in his (client) access token
*/
class MissingScopeException extends AbstractException
{
use EnumTrait;
Expand All @@ -16,10 +20,10 @@ public function __construct(array $scopeSlugs, Throwable $previous = null)
{
$scopeStrings = collect($scopeSlugs)
->map(fn (mixed $scopeSlug) => $this->getEnumValue($scopeSlug))
->toArray();
->join(', ');

parent::__construct(
'The used access token does not contain the required scope(s): ' . implode(', ', $scopeStrings) . '.',
'The used access token does not contain the required scope(s): ' . $scopeStrings . '.',
self::AUTH_MISSING_SCOPE,
Response::HTTP_FORBIDDEN,
$previous,
Expand Down
4 changes: 4 additions & 0 deletions src/Exceptions/ResourceNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
use Throwable;
use UnitEnum;

/**
* This exception should be thrown when a user attempts to fetch a resource
* which he doesn't have access to based on his permissions
*/
class ResourceNotFoundException extends AbstractException
{
use EnumTrait;
Expand Down
Loading