slovocast/app/src/Infrastructure/User/UserSessionManager.php

27 lines
683 B
PHP

<?php
namespace Slovocast\Infrastructure\User;
use Odan\Session\SessionInterface;
use Slovocast\Domain\Entity\User;
use Slovocast\Infrastructure\Api\User\UserSessionManagerInterface;
class UserSessionManager implements UserSessionManagerInterface
{
public function __construct(
protected SessionInterface $session
) { }
public function setUserAuthenticatedState(User $user): void
{
$this->session->set('authenticated', true);
$this->session->set('user', $user->toArray());
}
public function clearUserAuthenticatedState(): void
{
$this->session->delete('authenticated');
$this->session->delete('user');
}
}