<?php

declare(strict_types=1);

namespace apexl\Io\modules\authentication\controllers;

use apexl\Io\includes\Controller;
use JsonException;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

final readonly class authenticatedController extends Controller
{
    /**
     * @throws JsonException
     */
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
    {
        return $this->json($response, [
            'authenticated' => $request->getAttribute('authenticated', false),
        ]);
    }
}
