Sha256: fd40b84d40eae0e96d5d834671ad8b50428f0c3bf2773c3da2307932be4984c8

Contents?: true

Size: 592 Bytes

Versions: 18

Compression:

Stored size: 592 Bytes

Contents

# frozen_string_literal: true

module G5Authenticatable
  # Authorization helpers and error handling for controllers
  module Authorization
    extend ActiveSupport::Concern

    included do
      include Pundit
      rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
    end

    def user_not_authorized
      respond_to do |format|
        format.json do
          render status: :forbidden, json: { error: 'Access forbidden' }
        end
        format.html do
          render status: :forbidden, file: "#{Rails.root}/public/403"
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
g5_authenticatable-1.1.4 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.1.4.rc.3 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.1.4.rc.2 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.1.4.rc.1 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.1.2 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.1.2.pre.1 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.1.2.rc.5 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.1.2.rc.4 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.1.2.rc.3 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.1.2.rc.2 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.1.2.rc.1 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.1.1 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.1.0 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.0.0 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.0.0.pre.4 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.0.0.pre.3 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.0.0.pre.2 app/controllers/concerns/g5_authenticatable/authorization.rb
g5_authenticatable-1.0.0.pre.1 app/controllers/concerns/g5_authenticatable/authorization.rb