adasdsa
All checks were successful
Deploy / deploy-staging (push) Successful in 26s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-06-17 21:04:59 +02:00
parent 29b5987aac
commit dbb317927a
5 changed files with 65 additions and 3 deletions

View File

@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace App;
final class AuthStatusRedirect
{
private const COOKIE_NAME = 'desktop_auth_status_redirect';
public static function set(string $target): void
{
if ($target === '' || !str_starts_with($target, '/')) {
return;
}
setcookie(self::COOKIE_NAME, $target, [
'expires' => time() + 180,
'path' => '/',
'httponly' => true,
'samesite' => 'Lax',
]);
}
public static function consume(): ?string
{
$target = trim((string) ($_COOKIE[self::COOKIE_NAME] ?? ''));
self::clear();
if ($target === '' || !str_starts_with($target, '/')) {
return null;
}
return $target;
}
public static function clear(): void
{
setcookie(self::COOKIE_NAME, '', [
'expires' => time() - 3600,
'path' => '/',
'httponly' => true,
'samesite' => 'Lax',
]);
unset($_COOKIE[self::COOKIE_NAME]);
}
}