fix: detect system livewire requests via snapshot
This commit is contained in:
parent
1be262a756
commit
1b7e152594
@ -41,12 +41,61 @@ private function shouldUseSystemCookie(Request $request): bool
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->snapshotIndicatesSystemPanel($request)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$refererPath = parse_url((string) $request->headers->get('referer', ''), PHP_URL_PATH) ?? '';
|
$refererPath = parse_url((string) $request->headers->get('referer', ''), PHP_URL_PATH) ?? '';
|
||||||
$refererPath = '/'.ltrim((string) $refererPath, '/');
|
$refererPath = '/'.ltrim((string) $refererPath, '/');
|
||||||
|
|
||||||
return $refererPath === '/system' || str_starts_with($refererPath, '/system/');
|
return $refererPath === '/system' || str_starts_with($refererPath, '/system/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function snapshotIndicatesSystemPanel(Request $request): bool
|
||||||
|
{
|
||||||
|
if (! $request->is('livewire-*/update')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$components = $request->input('components');
|
||||||
|
|
||||||
|
if (! is_array($components)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($components as $componentPayload) {
|
||||||
|
if (! is_array($componentPayload)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$snapshot = $componentPayload['snapshot'] ?? null;
|
||||||
|
|
||||||
|
if (! is_string($snapshot) || $snapshot === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$decodedSnapshot = json_decode($snapshot, associative: true);
|
||||||
|
|
||||||
|
if (! is_array($decodedSnapshot)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $decodedSnapshot['memo']['path'] ?? null;
|
||||||
|
|
||||||
|
if (! is_string($path) || $path === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = '/'.ltrim($path, '/');
|
||||||
|
|
||||||
|
if ($path === '/system' || str_starts_with($path, '/system/')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private function systemCookieName(): string
|
private function systemCookieName(): string
|
||||||
{
|
{
|
||||||
return Str::slug((string) config('app.name', 'laravel')).'-system-session';
|
return Str::slug((string) config('app.name', 'laravel')).'-system-session';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user