16964 Remove role permissions

--HG--
branch : dev
This commit is contained in:
Suha Can
2010-12-08 14:04:33 -08:00
parent 2b15a8d56f
commit cc730fed3d
5 changed files with 11 additions and 41 deletions

View File

@@ -1,5 +1,6 @@
using Orchard.Localization;
using Orchard.UI.Navigation;
using Orchard.Security;
namespace Orchard.Roles {
public class AdminMenu : INavigationProvider {
@@ -9,7 +10,7 @@ namespace Orchard.Roles {
public void GetNavigation(NavigationBuilder builder) {
builder.Add(T("Users"), "40",
menu => menu.Add(T("Roles"), "2.0", item => item.Action("Index", "Admin", new { area = "Orchard.Roles" })
.Permission(Permissions.ManageRoles)));
.Permission(StandardPermissions.SiteOwner)));
}
}
}

View File

@@ -32,7 +32,7 @@ namespace Orchard.Roles.Controllers {
public ActionResult Index() {
if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles")))
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage roles")))
return new HttpUnauthorizedResult();
var model = new RolesIndexViewModel { Rows = _roleService.GetRoles().ToList() };
@@ -42,7 +42,7 @@ namespace Orchard.Roles.Controllers {
[HttpPost, ActionName("Index")]
public ActionResult IndexPOST() {
if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles")))
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage roles")))
return new HttpUnauthorizedResult();
try {
@@ -61,7 +61,7 @@ namespace Orchard.Roles.Controllers {
}
public ActionResult Create() {
if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles")))
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage roles")))
return new HttpUnauthorizedResult();
var model = new RoleCreateViewModel { FeaturePermissions = _roleService.GetInstalledPermissions() };
@@ -70,7 +70,7 @@ namespace Orchard.Roles.Controllers {
[HttpPost, ActionName("Create")]
public ActionResult CreatePOST() {
if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles")))
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage roles")))
return new HttpUnauthorizedResult();
var viewModel = new RoleCreateViewModel();
@@ -93,7 +93,7 @@ namespace Orchard.Roles.Controllers {
}
public ActionResult Edit(int id) {
if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles")))
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage roles")))
return new HttpUnauthorizedResult();
var role = _roleService.GetRole(id);
@@ -119,7 +119,7 @@ namespace Orchard.Roles.Controllers {
[HttpPost, ActionName("Edit")]
[FormValueRequired("submit.Save")]
public ActionResult EditSavePOST(int id) {
if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles")))
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage roles")))
return new HttpUnauthorizedResult();
var viewModel = new RoleEditViewModel();
@@ -152,7 +152,7 @@ namespace Orchard.Roles.Controllers {
[HttpPost]
public ActionResult Delete(int id, string returnUrl) {
if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles")))
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage roles")))
return new HttpUnauthorizedResult();
try {

View File

@@ -44,7 +44,7 @@ namespace Orchard.Roles.Drivers {
protected override DriverResult Editor(UserRolesPart userRolesPart, dynamic shapeHelper) {
// don't show editor without apply roles permission
if (!_authorizationService.TryCheckAccess(Permissions.ApplyRoles, _authenticationService.GetAuthenticatedUser(), userRolesPart))
if (!_authorizationService.TryCheckAccess(StandardPermissions.SiteOwner, _authenticationService.GetAuthenticatedUser(), userRolesPart))
return null;
return ContentShape("Parts_Roles_UserRoles_Edit",
@@ -64,7 +64,7 @@ namespace Orchard.Roles.Drivers {
protected override DriverResult Editor(UserRolesPart userRolesPart, IUpdateModel updater, dynamic shapeHelper) {
// don't apply editor without apply roles permission
if (!_authorizationService.TryCheckAccess(Permissions.ApplyRoles, _authenticationService.GetAuthenticatedUser(), userRolesPart))
if (!_authorizationService.TryCheckAccess(StandardPermissions.SiteOwner, _authenticationService.GetAuthenticatedUser(), userRolesPart))
return null;
var model = BuildEditorViewModel(userRolesPart);

View File

@@ -62,7 +62,6 @@
<Compile Include="Handlers\UserRolesPartHandler.cs" />
<Compile Include="Models\RolesPermissionsRecord.cs" />
<Compile Include="Models\UserRolesPartRecord.cs" />
<Compile Include="Permissions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\IRoleService.cs" />
<Compile Include="Services\RolesBasedAuthorizationService.cs" />

View File

@@ -1,30 +0,0 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using Orchard.Environment.Extensions.Models;
using Orchard.Security.Permissions;
namespace Orchard.Roles {
[UsedImplicitly]
public class Permissions : IPermissionProvider {
public static readonly Permission ManageRoles = new Permission { Description = "Create and manage roles", Name = "ManageRoles" };
public static readonly Permission ApplyRoles = new Permission { Description = "Assign users to roles", Name = "AssignUsersToRoles", ImpliedBy = new[] { ManageRoles } };
public virtual Feature Feature { get; set; }
public IEnumerable<Permission> GetPermissions() {
return new[] {
ManageRoles,
ApplyRoles,
};
}
public IEnumerable<PermissionStereotype> GetDefaultStereotypes() {
return new[] {
new PermissionStereotype {
Name = "Administrator",
Permissions = new[] {ManageRoles, ApplyRoles}
}
};
}
}
}