admin convenience for story/comment lookup

This commit is contained in:
Peter Bhat Harkins 2023-08-05 17:29:47 -05:00
parent d7e278213b
commit 26a7e87087
2 changed files with 6 additions and 0 deletions

View File

@ -378,6 +378,9 @@ private
def find_comment
comment = Comment.where(short_id: params[:id]).first
# convenience to use PK (from external queries) without generally permitting enumeration:
comment ||= Comment.find(params[:id]) if @user && @user.is_admin?
if @user && comment
comment.current_vote = Vote.where(:user_id => @user.id,
:story_id => comment.story_id, :comment_id => comment.id).first

View File

@ -416,6 +416,9 @@ private
def find_story
story = Story.find_by(:short_id => params[:story_id])
# convenience to use PK (from external queries) without generally permitting enumeration:
story ||= Story.find(params[:id]) if @user && @user.is_admin?
if @user && story
story.vote = Vote.find_by(
user: @user,