Sha256: d5259845b2d778d61b2292e9c485e4e7eb5a00083f411198074549249d7798a3

Contents?: true

Size: 535 Bytes

Versions: 5

Compression:

Stored size: 535 Bytes

Contents

module Rails
  module Auth
    module ErrorPage
      # Render an error page in the event Rails::Auth::NotAuthorizedError is raised
      class Middleware
        def initialize(app, page_body: nil)
          raise TypeError, "page_body must be a String" unless page_body.is_a?(String)

          @app       = app
          @page_body = page_body.freeze
        end

        def call(env)
          @app.call(env)
        rescue Rails::Auth::NotAuthorizedError
          [403, {}, [@page_body]]
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails-auth-0.5.1 lib/rails/auth/error_page/middleware.rb
rails-auth-0.5.0 lib/rails/auth/error_page/middleware.rb
rails-auth-0.4.1 lib/rails/auth/error_page/middleware.rb
rails-auth-0.4.0 lib/rails/auth/error_page/middleware.rb
rails-auth-0.3.0 lib/rails/auth/error_page/middleware.rb