class Facemock::OAuth::CallbackHook

Constants

DEFAULT_PATH

Attributes

path[RW]

Public Instance Methods

call(env) click to toggle source
Calls superclass method
# 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

Private Instance Methods

get_access_token(code) click to toggle source
# File lib/facemock/oauth/callback_hook.rb, line 25
def get_access_token(code)
  authorization_code = Facemock::AuthorizationCode.find_by_string(code)
  if authorization_code
    user = Facemock::User.find_by_id(authorization_code.user_id)
    user ? user.access_token : nil
  else
    nil
  end
end