mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
16979 Reports should check for site ownership
--HG-- branch : dev
This commit is contained in:
@@ -1,24 +1,38 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Orchard.Core.Reports.ViewModels;
|
using Orchard.Core.Reports.ViewModels;
|
||||||
|
using Orchard.Localization;
|
||||||
using Orchard.Reports.Services;
|
using Orchard.Reports.Services;
|
||||||
|
using Orchard.Security;
|
||||||
|
|
||||||
namespace Orchard.Core.Reports.Controllers {
|
namespace Orchard.Core.Reports.Controllers {
|
||||||
public class AdminController : Controller {
|
public class AdminController : Controller {
|
||||||
private readonly IReportsManager _reportsManager;
|
private readonly IReportsManager _reportsManager;
|
||||||
|
|
||||||
public AdminController(IReportsManager reportsManager) {
|
public AdminController(
|
||||||
|
IOrchardServices services,
|
||||||
|
IReportsManager reportsManager) {
|
||||||
|
Services = services;
|
||||||
_reportsManager = reportsManager;
|
_reportsManager = reportsManager;
|
||||||
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IOrchardServices Services { get; set; }
|
||||||
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
public ActionResult Index() {
|
public ActionResult Index() {
|
||||||
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list reports")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var model = new ReportsAdminIndexViewModel { Reports = _reportsManager.GetReports().ToList() };
|
var model = new ReportsAdminIndexViewModel { Reports = _reportsManager.GetReports().ToList() };
|
||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Display(int id) {
|
public ActionResult Display(int id) {
|
||||||
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to display report")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var model = new DisplayReportViewModel { Report = _reportsManager.Get(id) };
|
var model = new DisplayReportViewModel { Report = _reportsManager.Get(id) };
|
||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
|
Reference in New Issue
Block a user