update project
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContext;
|
||||
use App\Domain\SchoolCore\Context\SchoolContextStore;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
final class EnsureDomainProfile
|
||||
{
|
||||
public function __construct(private readonly SchoolContextStore $store) {}
|
||||
|
||||
public function handle(Request $request, Closure $next, string $profile): Response
|
||||
{
|
||||
/** @var SchoolContext|null $context */
|
||||
$context = $request->attributes->get(SchoolContext::class) ?? $this->store->current();
|
||||
|
||||
if (! $context || $context->domainProfile !== $profile) {
|
||||
abort(403, 'This route is not available for the current school domain profile.');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user