Skip to content

Commit

Permalink
logic for showing forum post edit buttons, and a fix
Browse files Browse the repository at this point in the history
  • Loading branch information
adelikat committed Jul 7, 2024
1 parent 6407240 commit 01af46c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion TASVideos/Pages/Forum/Posts/Edit.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task<IActionResult> OnGet()
return NotFound();
}

if (!CanEditPost(Post.PosterId))
if (!CanEditPost(post.PosterId))
{
return AccessDenied();
}
Expand Down
2 changes: 1 addition & 1 deletion TASVideos/Pages/Forum/Posts/User.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public async Task<IActionResult> OnGet()

var isOwnPost = post.PosterId == User.GetUserId();
var isOpenTopic = !post.TopicIsLocked;
post.IsEditable = User.Has(PermissionTo.EditUsersForumPosts) || (isOwnPost && isOpenTopic);
post.IsEditable = User.Has(PermissionTo.EditUsersForumPosts) || (isOwnPost && User.Has(PermissionTo.EditForumPosts) && isOpenTopic);

// Note: IsLastPost is always false, because calculating it for every topic is too expensive, so we only check permissions
// The goal here is for moderators to be able to modify posts from this screen, as a convenience
Expand Down
2 changes: 1 addition & 1 deletion TASVideos/Pages/Forum/Topics/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public async Task<IActionResult> OnGet()
var isOwnPost = post.PosterId == userId;
var isOpenTopic = !topic.IsLocked;
post.IsEditable = User.Has(PermissionTo.EditUsersForumPosts)
|| (isOwnPost && isOpenTopic);
|| (isOwnPost && User.Has(PermissionTo.EditForumPosts) && isOpenTopic);
post.IsDeletable = User.Has(PermissionTo.DeleteForumPosts)
|| (isOwnPost && isOpenTopic && post.IsLastPost);
}
Expand Down

0 comments on commit 01af46c

Please sign in to comment.