mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
[Fixes #6248] Prevent users from renaming their root folder
This commit is contained in:
@@ -83,6 +83,12 @@ namespace Orchard.MediaLibrary.Controllers {
|
|||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shouldn't be able to rename the root folder
|
||||||
|
if (IsRootFolder(folderPath)) {
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var viewModel = new MediaManagerFolderEditViewModel {
|
var viewModel = new MediaManagerFolderEditViewModel {
|
||||||
FolderPath = folderPath,
|
FolderPath = folderPath,
|
||||||
Name = folderPath.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar).Last()
|
Name = folderPath.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar).Last()
|
||||||
@@ -104,6 +110,11 @@ namespace Orchard.MediaLibrary.Controllers {
|
|||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shouldn't be able to rename the root folder
|
||||||
|
if(IsRootFolder(viewModel.FolderPath)) {
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_mediaLibraryService.RenameFolder(viewModel.FolderPath, viewModel.Name);
|
_mediaLibraryService.RenameFolder(viewModel.FolderPath, viewModel.Name);
|
||||||
Services.Notifier.Information(T("Media folder renamed"));
|
Services.Notifier.Information(T("Media folder renamed"));
|
||||||
@@ -165,5 +176,10 @@ namespace Orchard.MediaLibrary.Controllers {
|
|||||||
|
|
||||||
return Json(true);
|
return Json(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsRootFolder(string folderPath) {
|
||||||
|
var rootMediaFolder = _mediaLibraryService.GetRootMediaFolder();
|
||||||
|
return String.Equals(rootMediaFolder.MediaPath, folderPath, StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -609,5 +609,8 @@ $(function () {
|
|||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Select recent folder when the page is initialized.
|
||||||
|
viewModel.selectRecent();
|
||||||
})(window.mediaLibrarySettings);
|
})(window.mediaLibrarySettings);
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user