Sha256: 4a68a2460f8c947fb626f9e358895717eb706ddc893bc68de75dc906e4292ebe

Contents?: true

Size: 518 Bytes

Versions: 3

Compression:

Stored size: 518 Bytes

Contents

class ApplicationController < ActionController::Base
  before_action :authenticate_user!
  include Authz::Controllers::AuthorizationManager
  rescue_from Authz::Controllers::AuthorizationManager::NotAuthorized, with: :unauthorized_handler

  private

  def unauthorized_handler
    msg = 'Ooops! It seems that you are not authorized to do that!'
    respond_to do |format|
      format.html { redirect_back fallback_location: root_url, alert: msg }
      format.js{ render(js: "alert('#{msg}');") }
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
authz-0.0.1.alpha3 spec/dummy/app/controllers/application_controller.rb
authz-0.0.1.alpha2 spec/dummy/app/controllers/application_controller.rb
authz-0.0.1.alpha spec/dummy/app/controllers/application_controller.rb