mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
Refactoring permissions. First stage is renaming and collapsing some fine-grained permissions.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045742
This commit is contained in:
@@ -11,7 +11,9 @@ namespace Orchard.Core.Common {
|
||||
}
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new[] { ChangeOwner };
|
||||
return new Permission[] {
|
||||
ChangeOwner,
|
||||
};
|
||||
}
|
||||
|
||||
public IEnumerable<PermissionStereotype> GetDefaultStereotypes() {
|
||||
|
@@ -109,6 +109,7 @@
|
||||
<Compile Include="Scheduling\Services\ScheduledTaskExecutor.cs" />
|
||||
<Compile Include="Scheduling\Models\Task.cs" />
|
||||
<Compile Include="Settings\Controllers\SiteSettingsDriver.cs" />
|
||||
<Compile Include="Settings\Permissions.cs" />
|
||||
<Compile Include="Themes\Services\AdminThemeSelector.cs" />
|
||||
<Compile Include="Themes\Services\SafeModeThemeSelector.cs" />
|
||||
<Compile Include="Settings\AdminMenu.cs" />
|
||||
|
29
src/Orchard.Web/Core/Settings/Permissions.cs
Normal file
29
src/Orchard.Web/Core/Settings/Permissions.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Core.Settings {
|
||||
public class Permissions : IPermissionProvider {
|
||||
public static readonly Permission ManageSettings = new Permission { Name = "ManageSettings", Description = "Manage site settings" };
|
||||
public static readonly Permission ChangeSuperuser = new Permission { Name = "ChangeSuperuser", Description = "Change the superuser for the site" };
|
||||
|
||||
public string PackageName {
|
||||
get { return "Settings"; }
|
||||
}
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
ManageSettings,
|
||||
ChangeSuperuser,
|
||||
};
|
||||
}
|
||||
|
||||
public IEnumerable<PermissionStereotype> GetDefaultStereotypes() {
|
||||
return new[] {
|
||||
new PermissionStereotype {
|
||||
Name = "Administrators",
|
||||
//Permissions = new[] {ChangeOwner}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -40,7 +40,7 @@ namespace Orchard.Core.Themes.Controllers {
|
||||
[HttpPost]
|
||||
public ActionResult Activate(string themeName) {
|
||||
try {
|
||||
if (!_authorizer.Authorize(Permissions.SetSiteTheme, T("Couldn't set the current theme")))
|
||||
if (!_authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't set the current theme")))
|
||||
return new HttpUnauthorizedResult();
|
||||
_themeService.SetSiteTheme(themeName);
|
||||
return RedirectToAction("Index");
|
||||
@@ -58,7 +58,7 @@ namespace Orchard.Core.Themes.Controllers {
|
||||
[HttpPost]
|
||||
public ActionResult Install(FormCollection input) {
|
||||
try {
|
||||
if (!_authorizer.Authorize(Permissions.InstallUninstallTheme, T("Couldn't install theme")))
|
||||
if (!_authorizer.Authorize(Permissions.ManageThemes, T("Couldn't install theme")))
|
||||
return new HttpUnauthorizedResult();
|
||||
foreach (string fileName in Request.Files) {
|
||||
HttpPostedFileBase file = Request.Files[fileName];
|
||||
@@ -75,7 +75,7 @@ namespace Orchard.Core.Themes.Controllers {
|
||||
[HttpPost]
|
||||
public ActionResult Uninstall(string themeName) {
|
||||
try {
|
||||
if (!_authorizer.Authorize(Permissions.InstallUninstallTheme, T("Couldn't uninstall theme")))
|
||||
if (!_authorizer.Authorize(Permissions.ManageThemes, T("Couldn't uninstall theme")))
|
||||
return new HttpUnauthorizedResult();
|
||||
_themeService.UninstallTheme(themeName);
|
||||
return RedirectToAction("Index");
|
||||
|
@@ -4,8 +4,8 @@ using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Core.Themes {
|
||||
public class Permissions : IPermissionProvider {
|
||||
public static readonly Permission InstallUninstallTheme = new Permission { Description = "Installing or Uninstalling Themes", Name = "InstallUninstallTheme" };
|
||||
public static readonly Permission SetSiteTheme = new Permission { Description = "Setting the Current Theme", Name = "SetSiteTheme" };
|
||||
public static readonly Permission ManageThemes = new Permission { Description = "Manage Themes", Name = "ManageThemes" };
|
||||
public static readonly Permission ApplyTheme = new Permission { Description = "Apply a Theme", Name = "ApplyTheme" };
|
||||
|
||||
public string PackageName {
|
||||
get {
|
||||
@@ -14,9 +14,9 @@ namespace Orchard.Core.Themes {
|
||||
}
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new List<Permission> {
|
||||
SetSiteTheme,
|
||||
InstallUninstallTheme
|
||||
return new Permission[] {
|
||||
ManageThemes,
|
||||
ApplyTheme,
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user