<?php

declare(strict_types=1);

namespace App\Modules\Administration\Controllers;

use App\Controllers\Controller;
use App\Modules\Administration\Services\AuthenticationService;
use System\View\View;

final class AccessDeniedController extends Controller
{
    public function __construct(
        private AuthenticationService $authentication,
        View $view
    ) {
        parent::__construct($view);
    }

    public function index(): void
    {
        if (!$this->authentication->check()) {

            header(
                'Location: /public/login'
            );

            exit;
        }

        http_response_code(403);

        $this->render(
            'errors/403',
            [
                'title' => 'Access Denied'
            ]
        );
    }
}