Files
api/services/nginx/app/routes/attachmentsRoute.php
T
Bugfix Subagent 9025a8af6e fix(auth): add scope checks to remaining protected routes and fix scope test contract
Three fixes for the failing CI checks (PHP api, PHP integration):

1. RouteScopeTest.php: Pest's toContain() is variadic, so both arguments
   are treated as needles. The second 'description' argument was
   being treated as a needle, causing every file to fail. Removed the
   misleading second argument.

2. Added ScopeMiddleware::requireScope() calls and the matching
   Scope/ScopeMiddleware imports to 15 protected route files that
   the integration test contract requires.

3. documentation/auth/route-scope-audit.md: added the missing
   Scope::SUPERUSER_WRITE reference and a constants reference table.

Also registered tests/auth/StripeInvoiceEmailTemplateTest.php in the
legacy test manifest.
2026-08-17 13:22:09 +00:00

40 lines
1.2 KiB
PHP

<?php
namespace routes;
use classes\attachment_store;
use classes\response;
use traits\route_t;
use app\auth\Scope;
use app\auth\ScopeMiddleware;
class attachmentsRoute
{
use route_t;
public function run(): void
{
$this->get('/attachments/example', function (): never {
ScopeMiddleware::requireScope(Scope::CUSTOMER_READ, '/attachments/example');
throw new \Exception('EXAMPLE ROUTE, SHOULD BE IMPLEMENTED IN THE INDIVIDUAL OBJECT ROUTES');
});
$this->post('/attachments/upload', function () {
ScopeMiddleware::requireScope(Scope::CUSTOMER_WRITE, '/attachments/upload');
global $response;
self::requireParameters(['base64_image']);
$base64_image = self::getParameter('base64_image');
//self::requirePermission('modules_scanner_lpr');
if (empty($base64_image)) {
$response->error('Base64 image is required.');
}
$uploads = new attachment_store();
$object_name = $uploads->storeTempImageFromBase64(
$base64_image
);
echo $object_name;
$response->success(['object_name' => $object_name]);
});
}
}