Class: Reflex::Authlogic::CallbackFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/reflex/authlogic/callback_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ CallbackFilter

Returns a new instance of CallbackFilter.



4
5
6
# File 'lib/reflex/authlogic/callback_filter.rb', line 4

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/reflex/authlogic/callback_filter.rb', line 8

def call(env)
  # if :react_callback_method is available in the session and the requested URL's query
  # contains ReactOAuthSession, change the REQUEST_METHOD to :react_callback_method
  if env["rack.session"][:react_callback_method].present? && env["QUERY_STRING"] =~ /ReactOAuthSession/   
    env["REQUEST_METHOD"] = env["rack.session"].delete(:react_callback_method).to_s.upcase
    
    if env["rack.session"][:react_callback_location].present?
      location = env["rack.session"].delete(:react_callback_location)
      
      env["REQUEST_URI"] = location
      env["PATH_INFO"]   = location.split('?').first
    end
  end
  
  @app.call(env)
end