mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-19 01:57:55 +08:00
Adding permission check when updloading media from the admin
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.IO;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
@@ -27,6 +26,16 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
public ActionResult Index(string folderPath, string type) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageOwnMedia)) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
// Check permission.
|
||||
var rootMediaFolder = _mediaLibraryService.GetRootMediaFolder();
|
||||
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageMediaContent) && !_mediaLibraryService.CanManageMediaFolder(folderPath)) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
var viewModel = new ImportMediaViewModel {
|
||||
FolderPath = folderPath,
|
||||
|
Reference in New Issue
Block a user