<?php


namespace App\Http\Middleware;

use App\Cache\UserCache;
use App\Consts\ErrorConst;
use App\Facade\Site;
use App\Libs\Utils;
use Closure;
use App\Exceptions\ApiException;

class CheckLogin
{
    /**
     * @param         $request
     * @param Closure $next
     * @return mixed
     * @throws ApiException
     */
    public function handle($request, Closure $next)
    {
        $uid = Site::getUid();
        if (!$uid)  Utils::throwError(ErrorConst::NOT_LOGIN);

        return $next($request);
    }
}
