route; if (!$route || !isset($request->action)) { return $handler($request); } $controllerClass = $request->controller; $action = $request->action; $skipAuth = AnnotationHelper::getMethodAnnotation($controllerClass, $action, AllowAnonymous::class); if ($skipAuth && !$skipAuth->shouldRequireToken()) { return $handler($request); } try { $jwt = new JwtToken(); $userId = $jwt->id(); if (empty($userId)) { throw new UnauthorizedHttpException(); } } catch (\Exception $e) { return Json::fail($e->getMessage(), [], 401); } return $handler($request); } }