. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\FlashMessages; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Log; use Fisharebest\Webtrees\User; use Fisharebest\Webtrees\Validator; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function redirect; use function route; /** * Perform a logout. */ class Logout implements RequestHandlerInterface { /** * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $user = Validator::attributes($request)->user(); if ($user instanceof User) { Log::addAuthenticationLog('Logout: ' . Auth::user()->userName() . '/' . Auth::user()->realName()); Auth::logout(); FlashMessages::addMessage(I18N::translate('You have signed out.')); } return redirect(route(HomePage::class)); } }