Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions app/controllers/cards/comments/reactions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class Cards::Comments::ReactionsController < ApplicationController
include CardScoped

before_action :set_comment
before_action :set_reaction, only: %i[ destroy ]
before_action :ensure_permision_to_administer_reaction, only: %i[ destroy ]

def index
end
Expand All @@ -14,17 +16,19 @@ def create
end

def destroy
@reaction = @comment.reactions.find(params[:id])

if Current.user != @reaction.reacter
head :forbidden
else
@reaction.destroy
end
@reaction.destroy
end

private
def set_comment
@comment = @card.comments.find(params[:comment_id])
end

def set_reaction
@reaction = @comment.reactions.find(params[:id])
end

def ensure_permision_to_administer_reaction
head :forbidden if Current.user != @reaction.reacter
end
end