From fb5cc8ea03d015df05605b2fdb4612a52ae62080 Mon Sep 17 00:00:00 2001 From: Jeremy Friesen Date: Tue, 16 Apr 2024 10:42:45 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20endless=20and=20ever=20appeasing?= =?UTF-8?q?=20of=20the=20coppers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 27 +++++++++++-------- .../bulkrax/has_matchers_decorator.rb | 1 - 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1661c88bec..fd985944b1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +# rubocop:disable Metrics/ClassLength class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. @@ -26,7 +27,7 @@ class ApplicationController < ActionController::Base before_action :set_account_specific_connections! before_action :elevate_single_tenant!, if: :singletenant? skip_after_action :discard_flash_if_xhr - + rescue_from Apartment::TenantNotFound do raise ActionController::RoutingError, 'Not Found' end @@ -39,8 +40,8 @@ def hidden? def api_or_pdf? request.format.to_s.match('json') || - params[:print] || - request.path.include?('api') || + params[:print] || + request.path.include?('api') || request.path.include?('pdf') end @@ -82,14 +83,18 @@ def guest_user return @guest_user if @guest_user if session[:guest_user_id] # Override - added #unscoped to include guest users who are filtered out of User queries by default - @guest_user = User.unscoped.find_by(User.authentication_keys.first => session[:guest_user_id]) rescue nil - @guest_user = nil if @guest_user.respond_to? :guest and !@guest_user.guest + @guest_user = begin + User.unscoped.find_by(User.authentication_keys.first => session[:guest_user_id]) + rescue + nil + end + @guest_user = nil if @guest_user.respond_to?(:guest) && !@guest_user.guest end @guest_user ||= begin - u = create_guest_user(session[:guest_user_id]) - session[:guest_user_id] = u.send(User.authentication_keys.first) - u - end + u = create_guest_user(session[:guest_user_id]) + session[:guest_user_id] = u.send(User.authentication_keys.first) + u + end @guest_user end @@ -161,6 +166,6 @@ def append_info_to_payload(payload) super payload[:request_id] = request.uuid payload[:user_id] = current_user.id if current_user - payload[:account_id] = current_account.cname if current_account - end + payload[:account_id] = current_account.cname if current_account end +# rubocop:enable Metrics/ClassLength diff --git a/app/models/concerns/bulkrax/has_matchers_decorator.rb b/app/models/concerns/bulkrax/has_matchers_decorator.rb index 5bf269f432..d5edf99c9a 100644 --- a/app/models/concerns/bulkrax/has_matchers_decorator.rb +++ b/app/models/concerns/bulkrax/has_matchers_decorator.rb @@ -54,7 +54,6 @@ def geonames_lookup(result) end end - # Prepending this to `Bulkrax::HasMatchers` yielded an unbound method # Thus, I am prepending it to `Bulkrax::Entry` since that mixes in `Bulkrax::HasMatchers` Bulkrax::Entry.prepend(Bulkrax::HasMatchersDecorator)