From 0d2648d03069ea72ce0b9707db6d36913e241634 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sun, 1 Dec 2024 11:12:24 -0800 Subject: [PATCH] Move `support_staff?` method into `ApplicationController` I want to use it in a controller in our next change! --- app/controllers/application_controller.rb | 10 ++++++---- app/helpers/application_helper.rb | 4 ---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 82a2429e..1a3d973e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,7 +4,7 @@ require 'async/container' class ApplicationController < ActionController::Base protect_from_forgery - helper_method :current_user, :user_signed_in? + helper_method :current_user, :support_staff?, :user_signed_in? before_action :set_locale @@ -111,10 +111,12 @@ class ApplicationController < ActionController::Base return_to || root_path end + def support_staff? + current_user&.support_staff? + end + def support_staff_only - unless current_user&.support_staff? - raise AccessDenied, "Support staff only" - end + raise AccessDenied, "Support staff only" unless support_staff? end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 91f870c8..3e55c8ee 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -127,10 +127,6 @@ module ApplicationHelper !@hide_home_link end - def support_staff? - user_signed_in? && current_user.support_staff? - end - def impress_2020_meta_tags origin = Rails.configuration.impress_2020_origin support_secret = Rails.application.credentials.dig(