diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7264610533..1661c88bec 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,6 +5,8 @@ class ApplicationController < ActionController::Base # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception, prepend: true + force_ssl if: :ssl_configured? + helper Openseadragon::OpenseadragonHelper # Adds a few additional behaviors into the application controller include Blacklight::Controller @@ -23,7 +25,8 @@ class ApplicationController < ActionController::Base before_action :require_active_account!, if: :multitenant? 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 @@ -90,7 +93,6 @@ def guest_user @guest_user end - private def require_active_account! @@ -103,6 +105,10 @@ def set_account_specific_connections! current_account&.switch! end + def ssl_configured? + ActiveRecord::Type::Boolean.new.cast(current_account.ssl_configured) + end + def multitenant? @multitenant ||= ActiveModel::Type::Boolean.new.cast(ENV.fetch('HYKU_MULTITENANT', false)) end