mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 02:44:52 +08:00
Changing authorize calls to avoid demanding "Own" variations
The demand is adjusted if the user is the owner - but the "Own" variation is never used directly --HG-- branch : 1.x
This commit is contained in:
@@ -32,7 +32,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public ActionResult Create() {
|
||||
if (!Services.Authorizer.Authorize(Permissions.EditOwnBlogPost, T("Not allowed to create blog post")))
|
||||
if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, T("Not allowed to create blog post")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var blogPost = Services.ContentManager.New<BlogPostPart>("BlogPost");
|
||||
@@ -56,14 +56,14 @@ namespace Orchard.Blogs.Controllers {
|
||||
[HttpPost, ActionName("Create")]
|
||||
[FormValueRequired("submit.Publish")]
|
||||
public ActionResult CreateAndPublishPOST() {
|
||||
if (!Services.Authorizer.Authorize(Permissions.PublishOwnBlogPost, T("Couldn't create blog post")))
|
||||
if (!Services.Authorizer.Authorize(Permissions.PublishBlogPost, T("Couldn't create blog post")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
return CreatePOST(contentItem => Services.ContentManager.Publish(contentItem));
|
||||
}
|
||||
|
||||
public ActionResult CreatePOST(Action<ContentItem> conditionallyPublish) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.EditOwnBlogPost, T("Couldn't create blog post")))
|
||||
if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, T("Couldn't create blog post")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var blogPost = Services.ContentManager.New<BlogPostPart>("BlogPost");
|
||||
|
@@ -128,11 +128,12 @@ namespace Orchard.Blogs.Services {
|
||||
|
||||
IUser user = ValidateUser(userName, password);
|
||||
|
||||
// User needs to at least have permission to edit its own blog posts to access the service
|
||||
_authorizationService.CheckAccess(Permissions.EditOwnBlogPost, user, null);
|
||||
|
||||
XRpcArray array = new XRpcArray();
|
||||
foreach (BlogPart blog in _blogService.Get()) {
|
||||
// User needs to at least have permission to edit its own blog posts to access the service
|
||||
_authorizationService.CheckAccess(Permissions.EditBlogPost, user, blog);
|
||||
|
||||
BlogPart blogPart = blog;
|
||||
array.Add(new XRpcStruct()
|
||||
.Set("url", urlHelper.AbsoluteAction(() => urlHelper.Blog(blogPart)))
|
||||
@@ -154,7 +155,7 @@ namespace Orchard.Blogs.Services {
|
||||
IUser user = ValidateUser(userName, password);
|
||||
|
||||
// User needs to at least have permission to edit its own blog posts to access the service
|
||||
_authorizationService.CheckAccess(Permissions.EditOwnBlogPost, user, null);
|
||||
_authorizationService.CheckAccess(Permissions.EditBlogPost, user, null);
|
||||
|
||||
BlogPart blog = _contentManager.Get<BlogPart>(Convert.ToInt32(blogId));
|
||||
if (blog == null) {
|
||||
@@ -184,7 +185,7 @@ namespace Orchard.Blogs.Services {
|
||||
IUser user = ValidateUser(userName, password);
|
||||
|
||||
// User needs permission to edit or publish its own blog posts
|
||||
_authorizationService.CheckAccess(publish ? Permissions.PublishOwnBlogPost : Permissions.EditOwnBlogPost, user, null);
|
||||
_authorizationService.CheckAccess(publish ? Permissions.PublishBlogPost : Permissions.EditBlogPost, user, null);
|
||||
|
||||
BlogPart blog = _contentManager.Get<BlogPart>(Convert.ToInt32(blogId));
|
||||
if (blog == null)
|
||||
|
Reference in New Issue
Block a user