Sha256: 527b8235c1e95a2be69b9b3d4581e8e0fccfab2b08eb193cb7edb14ad37ee620
Contents?: true
Size: 811 Bytes
Versions: 1
Compression:
Stored size: 811 Bytes
Contents
require 'facemock' module Facemock module OAuth class CallbackHook < RackMiddleware DEFAULT_PATH = "/users/auth/callback" @path = DEFAULT_PATH 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 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
facemock-oauth-0.0.4 | lib/facemock/oauth/callback_hook.rb |