Class: Facemock::OAuth::CallbackHook

Inherits:
RackMiddleware show all
Defined in:
lib/facemock/oauth/callback_hook.rb

Constant Summary collapse

DEFAULT_PATH =
"/users/auth/callback"

Class Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RackMiddleware

#initialize

Constructor Details

This class inherits a constructor from Facemock::OAuth::RackMiddleware

Class Attribute Details

.pathObject

Returns the value of attribute path.



7
8
9
# File 'lib/facemock/oauth/callback_hook.rb', line 7

def path
  @path
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/facemock/oauth/callback_hook.rb', line 13

def call(env)
  if env["PATH_INFO"] == CallbackHook.path
    query = query_string_to_hash(env["QUERY_STRING"])
    if access_token = get_access_token(query["code"])
      env["omniauth.auth"] = Facemock.auth_hash(access_token)
    end
  end
  super(env)
end