blogging: Let users delete their own comments

pull/3036/head
Yunus Emre Kalkan 6 years ago
parent 4a0567a038
commit b0adb9ff09

@ -35,6 +35,11 @@ namespace Volo.Blogging.Comments
private async Task<bool> HasDeletePermission(AuthorizationHandlerContext context, Comment resource)
{
if (resource.CreatorId != null && resource.CreatorId == context.User.FindUserId())
{
return true;
}
if (await _permissionChecker.IsGrantedAsync(context.User, BloggingPermissions.Comments.Delete))
{
return true;

@ -35,6 +35,11 @@ namespace Volo.Blogging.Posts
private async Task<bool> HasDeletePermission(AuthorizationHandlerContext context, Post resource)
{
if (resource.CreatorId != null && resource.CreatorId == context.User.FindUserId())
{
return true;
}
if (await _permissionChecker.IsGrantedAsync(context.User, BloggingPermissions.Posts.Delete))
{
return true;

@ -45,7 +45,7 @@ namespace Volo.Blogging
[Route("{id}")]
public Task DeleteAsync(Guid id)
{
throw new NotImplementedException();
return _commentAppService.DeleteAsync(id);
}
}
}

@ -147,7 +147,7 @@
</a>
}
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Delete))
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Delete) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<span class="seperator">|</span>
<a href="#" class="tag deleteLink" data-deleteid="@commentWithRepliesDto.Comment.Id">

Loading…
Cancel
Save