Class: Passport::Filter
- Inherits:
-
Object
- Object
- Passport::Filter
- Defined in:
- lib/passport/helpers/filter.rb
Constant Summary collapse
- METHODS =
%w(get head put post delete options)
Instance Method Summary collapse
-
#call(env) ⇒ Object
this intercepts how the browser interprets the url.
-
#initialize(app) ⇒ Filter
constructor
A new instance of Filter.
Constructor Details
#initialize(app) ⇒ Filter
Returns a new instance of Filter.
6 7 8 |
# File 'lib/passport/helpers/filter.rb', line 6 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
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”
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/passport/helpers/filter.rb', line 14 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 |