Sha256: 4b5a336afd0bbcd031377a3d11b96cad6328f9868916d2dc25cad423b9960032

Contents?: true

Size: 1013 Bytes

Versions: 16

Compression:

Stored size: 1013 Bytes

Contents

class ApplicationController < ActionController::Base
  ALLOWABLE_CONFIGS = %w(github_ref github_owner github_app_name github_repo)

  if Authentication.type.disabled?
    before_action :set_guest_user
  else
    before_action :authenticate_user!
  end
  before_filter :set_hostname
  before_filter :set_cache_buster
  helper_method :app_config

  rescue_from CanCan::AccessDenied do
    #redirect_to unauthorized_path
    render :unauthorized, layout: false, status: :unauthorized
  end

  private

  def app_config
    APP_CONFIG.select { |k, _| ALLOWABLE_CONFIGS.include?(k) }.to_json
  end

  def set_hostname
    @hostname = request.host
  end

  def set_cache_buster
    response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
    response.headers["Pragma"] = "no-cache"
    response.headers["Expires"] = "#{1.year.ago}"
  end

  def set_guest_user
    logger.warn('AUTHENTICATION DISABLED: SIGNING IN GUEST USER') if Rails.env.production?
    sign_in(User.guest_user)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aleph_analytics-0.4.9.pre.dev app/controllers/application_controller.rb
aleph_analytics-0.4.8 app/controllers/application_controller.rb
aleph_analytics-0.4.7 app/controllers/application_controller.rb
aleph_analytics-0.4.4 app/controllers/application_controller.rb
aleph_analytics-0.4.2 app/controllers/application_controller.rb
aleph_analytics-0.4.1 app/controllers/application_controller.rb
aleph_analytics-0.3.0 app/controllers/application_controller.rb
aleph_analytics-0.2.0 app/controllers/application_controller.rb
aleph_analytics-0.1.0 app/controllers/application_controller.rb
aleph_analytics-0.0.6 app/controllers/application_controller.rb
aleph_analytics-0.0.5 app/controllers/application_controller.rb
aleph_analytics-0.0.4 app/controllers/application_controller.rb
aleph_analytics-0.0.3 app/controllers/application_controller.rb
aleph_analytics-0.0.2 app/controllers/application_controller.rb
aleph_analytics-0.0.1.alpha app/controllers/application_controller.rb
aleph_analytics-0.0.0.alpha app/controllers/application_controller.rb