From 8fc0f577d7eb5534b240e9da321f75e64ba6a221 Mon Sep 17 00:00:00 2001 From: saiaakarsh-tamu Date: Mon, 4 Nov 2024 08:49:52 -0600 Subject: [PATCH] Checking whther a user is admin first instead of his user id for survey responses --- .../app/controllers/survey_responses_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rails_root/app/controllers/survey_responses_controller.rb b/rails_root/app/controllers/survey_responses_controller.rb index a54d56a..7b25714 100644 --- a/rails_root/app/controllers/survey_responses_controller.rb +++ b/rails_root/app/controllers/survey_responses_controller.rb @@ -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