Sha256: 3a9865e798e208749df738e6fdfe027aa60e39830c05e4e71edd198a42badd8f

Contents?: true

Size: 828 Bytes

Versions: 14

Compression:

Stored size: 828 Bytes

Contents

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

  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.21.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.20.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.19.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.18.1 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.18.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.17.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.16.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.15.3 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.15.2 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.15.1 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.15.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.14.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.13.0 app/controllers/wcms_application_controller.rb
biola_wcms_components-0.12.0 app/controllers/wcms_application_controller.rb