mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-31 21:08:54 +08:00
[Fixes #6248] Prevent users from renaming their root folder
This commit is contained in:
parent
f17f2c3a93
commit
eb7574df0b
@ -83,6 +83,12 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
// Shouldn't be able to rename the root folder
|
||||
if (IsRootFolder(folderPath)) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
|
||||
var viewModel = new MediaManagerFolderEditViewModel {
|
||||
FolderPath = folderPath,
|
||||
Name = folderPath.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar).Last()
|
||||
@ -104,6 +110,11 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
// Shouldn't be able to rename the root folder
|
||||
if(IsRootFolder(viewModel.FolderPath)) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
try {
|
||||
_mediaLibraryService.RenameFolder(viewModel.FolderPath, viewModel.Name);
|
||||
Services.Notifier.Information(T("Media folder renamed"));
|
||||
@ -165,5 +176,10 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
|
||||
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;
|
||||
});
|
||||
|
||||
// Select recent folder when the page is initialized.
|
||||
viewModel.selectRecent();
|
||||
})(window.mediaLibrarySettings);
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user