feat(auth): implement permission-based access for scanner functionality and update related tests

This commit is contained in:
2026-08-11 14:26:28 -03:00
parent 3eaa3f8202
commit 7d9489169d
10 changed files with 81 additions and 22 deletions

View File

@@ -2,7 +2,7 @@
namespace App\Http\Middleware;
use App\Domains\Authorization\Enums\RoleCode;
use App\Domains\Authorization\Enums\PermissionCode;
use Closure;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\Request;
@@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Response;
class EnsureScannerTenant
{
/**
* Ensure the authenticated user is a scanner bound to a tenant.
* Ensure the authenticated user can scan tickets for a tenant.
*/
public function handle(Request $request, Closure $next): Response
{
@@ -19,8 +19,8 @@ class EnsureScannerTenant
if (
! $user
|| $user->rol_codigo !== RoleCode::Scanner->value
|| ! $user->tenant_codigo
|| ! $user->hasPermission(PermissionCode::ScanTickets->value)
) {
throw new AuthorizationException;
}