Sha256: e4685d25f03413821bd3044807c23fe435d14e82772086919f80ab6fca03a955

Contents?: true

Size: 869 Bytes

Versions: 14

Compression:

Stored size: 869 Bytes

Contents

# ApplicationController should inherit from this controller.
class WcmsApplicationController < ActionController::Base
  include Pundit

  protect_from_forgery with: :exception

  before_action :authenticate!
  after_action :verify_authorized
  after_action :verify_policy_scoped, only: :index
  rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized

  layout -> { (@layout || :application).to_s }

  helper_method :current_user
  def current_user
    authentication.user
  end

  protected

  def authenticate!
    authentication.perform or render_error_page(401)
  end

  def authentication
    @authentication ||= CasAuthentication.new(session)
  end

  def render_error_page(status)
    render file: "#{Rails.root}/public/#{status}", formats: [:html], status: status, layout: false
  end

  def user_not_authorized
    render_error_page(403)
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
biola_wcms_components-0.11.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.10.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.9.1 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.9.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.8.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.7.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.6.1 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.6.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.5.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.4.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.3.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.2.1 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.2.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.1.0 app/controllers/wcms_application_controller.rb