Sha256: fc906454230ca08fd798ec54781963e08345b53f341bf59ad7dde1a1c9d5b607
Contents?: true
Size: 831 Bytes
Versions: 3
Compression:
Stored size: 831 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::Database::AuthorizationCode.find_by_string(code) if authorization_code user = Facemock::Database::User.find_by_id(authorization_code.user_id) user ? user.access_token : nil else nil end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
facemock-oauth-0.0.3 | lib/facemock/oauth/callback_hook.rb |
facemock-oauth-0.0.2 | lib/facemock/oauth/callback_hook.rb |
facemock-oauth-0.0.1 | lib/facemock/oauth/callback_hook.rb |