blog module basic auth on delete

pull/441/head
Yunus Emre Kalkan 7 years ago
parent 83c506d2bc
commit 4d3858ecce

@ -80,8 +80,26 @@ namespace Volo.Blogging.Comments
return ObjectMapper.Map<Comment, CommentDto>(comment);
}
[Authorize(BloggingPermissions.Comments.Delete)]
public async Task DeleteAsync(Guid id)
{
var comment = await _commentRepository.GetAsync(id);
if (CurrentUser.Id != comment.CreatorId)
{
await DeleteAsAdminAsync(id);
return;
}
await DeleteCommentAsync(id);
}
[Authorize(BloggingPermissions.Comments.Delete)]
private async Task DeleteAsAdminAsync(Guid id)
{
await DeleteCommentAsync(id);
}
private async Task DeleteCommentAsync(Guid id)
{
await _commentRepository.DeleteAsync(id);

@ -183,7 +183,7 @@
<i class="fa fa-reply" aria-hidden="true"></i> @L["Reply"]
</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" data-deleteid="@reply.Id">

Loading…
Cancel
Save