Пример #1
0
        public List<ApiResponse> Rejections(int id, out ApiRequest request, out ConfigurationPart part) {

            var context = _orchardServices.WorkContext.HttpContext;
            request = new ApiRequest(ApiRequestType.Configuration) { Stopwatch = _stopwatch };
            var response = new List<ApiResponse>();

            if (id == 0) {
                Logger.Error("No Configuration for id 0.  Requested by {1} at {2}.", context.User.Identity.IsAuthenticated ? context.User.Identity.Name : "Anonymous", context.Request.UserHostAddress);
                response.Add(NotFound(request));
                part = null;
                return response;
            }

            part = _orchardServices.ContentManager.Get(id).As<ConfigurationPart>();

            if (part == null) {
                Logger.Error("No Configuration for id {0}.  Requested by {1} at {2}.", id, context.User.Identity.IsAuthenticated ? context.User.Identity.Name : "Anonymous", context.Request.UserHostAddress);
                response.Add(NotFound(request));
                return response;
            }

            if (context.Request.IsLocal || part.IsInAllowedRange(context.Request.UserHostAddress)) {
                return response;
            }

            if (_orchardServices.Authorizer.Authorize(global::Orchard.Core.Contents.Permissions.ViewContent, part)) {
                return response;
            }

            Logger.Error("Not authorized to run {0}.  Requested by {1} at {2}.", part.As<TitlePart>().Title, context.User.Identity.Name, context.Request.UserHostAddress);
            response.Add(Unathorized(request));
            return response;
        }
Пример #2
0
        private FilePart CreateOutputFile(ConfigurationPart part)
        {
            var prefix   = Slugify(part.As <TitlePart>().Title);
            var filePart = _fileService.Create(prefix, part.OutputFileExtension);

            _filesCreated.Add(filePart.Id);
            return(filePart);
        }
Пример #3
0
        public List <ApiResponse> Rejections(int id, out ApiRequest request, out ConfigurationPart part)
        {
            var context = _orchardServices.WorkContext.HttpContext;

            request = new ApiRequest(ApiRequestType.Configuration)
            {
                Stopwatch = _stopwatch
            };
            var response = new List <ApiResponse>();

            if (id == 0)
            {
                Logger.Error("No Configuration for id 0.  Requested by {1} at {2}.", context.User.Identity.IsAuthenticated ? context.User.Identity.Name : "Anonymous", context.Request.UserHostAddress);
                response.Add(NotFound(request));
                part = null;
                return(response);
            }

            part = _orchardServices.ContentManager.Get(id).As <ConfigurationPart>();

            if (part == null)
            {
                Logger.Error("No Configuration for id {0}.  Requested by {1} at {2}.", id, context.User.Identity.IsAuthenticated ? context.User.Identity.Name : "Anonymous", context.Request.UserHostAddress);
                response.Add(NotFound(request));
                return(response);
            }

            if (context.Request.IsLocal || part.IsInAllowedRange(context.Request.UserHostAddress))
            {
                return(response);
            }

            if (_orchardServices.Authorizer.Authorize(global::Orchard.Core.Contents.Permissions.ViewContent, part))
            {
                return(response);
            }

            Logger.Error("Not authorized to run {0}.  Requested by {1} at {2}.", part.As <TitlePart>().Title, context.User.Identity.Name, context.Request.UserHostAddress);
            response.Add(Unathorized(request));
            return(response);
        }
 private FilePart CreateOutputFile(ConfigurationPart part) {
     var prefix = Slugify(part.As<TitlePart>().Title);
     var filePart = _fileService.Create(prefix, part.OutputFileExtension);
     _filesCreated.Add(filePart.Id);
     return filePart;
 }