<?php

declare(strict_types=1);

namespace App\Middleware;

use App\Core\Auth;
use App\Core\Request;

class AuthMiddleware implements MiddlewareInterface
{
    public function handle(Request $request, callable $next, array $params = []): mixed
    {
        if (!Auth::check()) {
            flash('error', 'Debes iniciar sesión para continuar.');
            redirect('login');
        }

        return $next($request);
    }
}
