Created
October 8, 2011 10:58
-
-
Save josevalim/1272143 to your computer and use it in GitHub Desktop.
Dynamic omniauth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OmniauthController < ApplicationController | |
def start | |
request_phase(:facebook, client_id, client_secret) | |
end | |
def callback | |
callback_phase(:facebook, client_id, client_secret) do | |
render :text => "Done!" | |
end | |
end | |
def request_phase(name, *args, &block) | |
strategy = ::OmniAuth::Strategies.const_get(::OmniAuth::Utils.camelize(name.to_s)) | |
block ||= lambda { |env| [404, { "Content-Type" => "text/plain" }, []] } | |
strategy.new(block, name, *args).call(env) | |
end | |
def callback_phase(name, *args, &block) | |
strategy = ::OmniAuth::Strategies.const_get(::OmniAuth::Utils.camelize(name.to_s)) | |
strategy.new(block, name, *args).call(env) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment