Skip to content

Commit

Permalink
🎁 Porting over ApplicationController from PALs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyf committed Apr 16, 2024
1 parent 1290e60 commit eceafed
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -90,7 +93,6 @@ def guest_user
@guest_user
end


private

def require_active_account!
Expand All @@ -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
Expand Down

0 comments on commit eceafed

Please sign in to comment.