- Detect form-encoded action=... requests, so form-encoded updates work and unhandled actions are no longer created as notes - Default to h-entry when no type is given - Read form-encoded photos from `photo` rather than `photos` - Pass `category` through EntryData so bookmark tags are saved - Accept single values for form-encoded multi-value properties - Return 403 for insufficient_scope and 401 for invalid tokens - Return 400 invalid_request for unsupported post types, update operations and models instead of reporting them as 500s Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Http\Responses;
|
||
|
||
use Illuminate\Http\JsonResponse;
|
||
|
||
class MicropubResponses
|
||
{
|
||
/**
|
||
* Generate a response to be returned when the token has insufficient scope.
|
||
*/
|
||
public function insufficientScopeResponse(): JsonResponse
|
||
{
|
||
return response()->json([
|
||
'response' => 'error',
|
||
'error' => 'insufficient_scope',
|
||
'error_description' => 'The token’s scope does not have the necessary requirements.',
|
||
], 403);
|
||
}
|
||
|
||
/**
|
||
* Generate a response to be returned when the token is invalid.
|
||
*/
|
||
public function invalidTokenResponse(): JsonResponse
|
||
{
|
||
return response()->json([
|
||
'response' => 'error',
|
||
'error' => 'invalid_token',
|
||
'error_description' => 'The provided token did not pass validation',
|
||
], 401);
|
||
}
|
||
|
||
/**
|
||
* Generate a response to be returned when the token has no scope.
|
||
*/
|
||
public function tokenHasNoScopeResponse(): JsonResponse
|
||
{
|
||
return response()->json([
|
||
'response' => 'error',
|
||
'error' => 'invalid_request',
|
||
'error_description' => 'The provided token has no scopes',
|
||
], 400);
|
||
}
|
||
}
|