Skip to content

Commit

Permalink
Merge pull request #16 from tamu-edu-students/sprint3-nithin
Browse files Browse the repository at this point in the history
Checking whther a user is admin first instead of his user id for surv…
  • Loading branch information
saiaakarsh-tamu authored Nov 4, 2024
2 parents 93d4faf + 8fc0f57 commit 107e041
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rails_root/app/controllers/survey_responses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ def index
# GET /survey_responses/1 or /survey_responses/1.json
def show
return return_to_root 'You are not logged in.' if current_user_id.nil?
return return_to_root 'You cannot view this result.' if current_user_id != @survey_response.profile.user_id && !user_is_admin?

return return_to_root 'You cannot view this result.' if !user_is_admin? && (current_user_id != @survey_response.profile.user_id)
flash.keep(:warning)

respond_to do |format|
format.html
format.xlsx do
format.xlsx {
response.headers['Content-Disposition'] = "attachment; filename=survey_response_#{@survey_response.id}.xlsx"
end
}
end
end

Expand Down

0 comments on commit 107e041

Please sign in to comment.