feat(auth): implement permission-based access for scanner functionality and update related tests
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user