Permitir consulta pública dos ecrãs reais com dados privados protegidos
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Services\EvaluationAccess;
|
||||
use App\Services\PublicNavigation;
|
||||
use App\Services\RequisitionWorkflow;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -14,6 +15,9 @@ class EnterLocalEvaluation
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$access = app(EvaluationAccess::class);
|
||||
if (app(PublicNavigation::class)->enabled()) {
|
||||
return $next($request);
|
||||
}
|
||||
if (! $access->dashboardEntry($request)) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Services\PublicNavigation;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class PublicDevelopmentNavigation
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$navigation = app(PublicNavigation::class);
|
||||
if (! $navigation->enabled() || $request->user('web') !== null || ! in_array($request->method(), ['GET', 'HEAD'], true)) {
|
||||
return $next($request);
|
||||
}
|
||||
$path = '/'.$request->path();
|
||||
if ($request->path() === '/') {
|
||||
return redirect('/dashboard');
|
||||
}
|
||||
if (! isset(PublicNavigation::PAGES[$path])) {
|
||||
return $next($request);
|
||||
}
|
||||
$response = Inertia::render(PublicNavigation::PAGES[$path], $navigation->props($request))->toResponse($request);
|
||||
$response->headers->set('Cache-Control', 'private, no-store, max-age=0');
|
||||
$response->headers->set('X-Robots-Tag', 'noindex, nofollow');
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user