<?php
/// file: app/Middleware/AuthMiddleware.php

declare(strict_types=1);

namespace App\Middleware;

use App\Core\App;
use App\Core\Auth;
use App\Core\Redirect;
use App\Core\Request;
use App\Core\Response;

final class AuthMiddleware
{
    public function __construct(private readonly App $app)
    {
    }

    public function handle(Request $request, App $app): ?Response
    {
        $auth = new Auth();
        if (! $auth->check()) {
            return Redirect::to(url('/admin/login'));
        }
        return null;
    }
}
