Sha256: 7a36540fe865ecdc80f4ab05055e738039e3b272f98b278fcb7f513cfd85c43e

Contents?: true

Size: 930 Bytes

Versions: 1

Compression:

Stored size: 930 Bytes

Contents

# http://github.com/manveru/innate/blob/master/lib/innate/current.rb
module Passport
  class Filter
    METHODS = %w(get head put post delete options)
    
    def initialize(app)
      @app = app
    end
    
    # this intercepts how the browser interprets the url.
    # so we override it and say,
    # "if we've stored a variable in the session called :auth_callback_method,
    # then convert that into a POST call so we re-call the original method"
    def call(env)
      if env["rack.session"].nil?
        raise "Make sure you are setting the session in Rack too!  Place this in config/application.rb"
      end
      
      unless env["rack.session"][:auth_callback_method].blank?
        method = env["rack.session"].delete(:auth_callback_method).to_s.downcase
        method = "get" unless METHODS.include?(method)
        env["REQUEST_METHOD"] = method.upcase
      end
      
      @app.call(env)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
passport-0.1.1 lib/passport/helpers/filter.rb