CheckLogin.php 515 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace App\Http\Middleware;
  3. use App\Cache\UserCache;
  4. use App\Consts\ErrorConst;
  5. use App\Facade\Site;
  6. use App\Libs\Utils;
  7. use Closure;
  8. use App\Exceptions\ApiException;
  9. class CheckLogin
  10. {
  11. /**
  12. * @param $request
  13. * @param Closure $next
  14. * @return mixed
  15. * @throws ApiException
  16. */
  17. public function handle($request, Closure $next)
  18. {
  19. $uid = Site::getUid();
  20. if (!$uid) Utils::throwError(ErrorConst::NOT_LOGIN);
  21. return $next($request);
  22. }
  23. }