-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix blogging module post detail page permission check. #3099
Conversation
hi @gdlcf88 Can you resolve the conflict? Conflicting files
|
I will do it. |
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When hasCommentingPermission
is false
, a link in the page will redirect the user to the login page.
We should handle this situation. It may be not logged in or without permissions.
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Posts.Delete)) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users are not allowed to delete their own Posts?
abp/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAuthorizationHandler.cs
Line 38 in b0adb9f
if (resource.CreatorId != null && resource.CreatorId == context.User.FindUserId()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users are not allowed to delete their own Posts?
abp/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAuthorizationHandler.cs
Line 38 in b0adb9f
if (resource.CreatorId != null && resource.CreatorId == context.User.FindUserId())
Sorry, my branch missed this commit:
b0adb9f#diff-e461a1b98fc07088163606c19001917c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can merge dev
into your branch.
@@ -57,14 +57,14 @@ | |||
<i class="fa fa-comment"></i> @L["CommentWithCount", @Model.CommentCount] | |||
|
|||
|
|||
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Posts.Update)) | |||
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Posts.Update) || (CurrentUser.Id.HasValue && CurrentUser.Id == Model.Post.CreatorId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(CurrentUser.Id.HasValue && CurrentUser.Id == Model.Post.CreatorId)
can be CurrentUser.Id == Model.Post.CreatorId
{ | ||
<span class="seperator">|</span> | ||
<a href="#" class="tag deleteLink" data-deleteid="@commentWithRepliesDto.Comment.Id"> | ||
<i class="fa fa-trash" aria-hidden="true"></i> @L["Delete"] | ||
</a> | ||
} | ||
|
||
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) | ||
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id.HasValue && CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId
@@ -200,7 +200,7 @@ | |||
</div> | |||
</div> | |||
} | |||
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) | |||
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id.HasValue && CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId
{ | ||
<span class="seperator">|</span> | ||
<a href="#" class="tag deleteLink" data-deleteid="@reply.Id"> | ||
<i class="fa fa-trash" aria-hidden="true"></i> @L["Delete"] | ||
</a> | ||
} | ||
|
||
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) | ||
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id.HasValue && CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId
@@ -276,7 +276,7 @@ | |||
</div> | |||
</div> | |||
} | |||
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) | |||
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id.HasValue && CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId
@@ -238,15 +238,15 @@ | |||
<i class="fa fa-reply" aria-hidden="true"></i> @L["Reply"] | |||
</a> | |||
} | |||
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Delete) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to merge the latest branch since the creator check was added into AuthorizationHandler 4 days ago. 😅
@@ -160,15 +160,15 @@ | |||
</a> | |||
} | |||
|
|||
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Delete) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId
?
Fix #3098