Sha256: f40c17795fa92b6d3c2ae047743ad5db6e9de5e1b3f1514a033b0154b44126c3

Contents?: true

Size: 1.73 KB

Versions: 6

Compression:

Stored size: 1.73 KB

Contents

module AuthlogicOauth
  module OauthProcess
    
  private
  
    def validate_by_oauth
      validate_email_field = false
      
      if oauth_response.blank?
        redirect_to_oauth
      else
        authenticate_with_oauth
      end
    end
    
    def redirecting_to_oauth_server?
      authenticating_with_oauth? && oauth_response.blank?
    end
    
    def redirect_to_oauth
      request = oauth.get_request_token :oauth_callback => build_callback_url
      oauth_controller.session[:oauth_request_token]        = request.token
      oauth_controller.session[:oauth_request_token_secret] = request.secret
      
      # Tell our rack callback filter what method the current request is using
      oauth_controller.session[:oauth_callback_method]      = oauth_controller.request.method
      
      oauth_controller.redirect_to request.authorize_url
    end
    
    def build_callback_url
      oauth_controller.url_for :controller => oauth_controller.controller_name, :action => oauth_controller.action_name
    end
    
    def request_token
      OAuth::RequestToken.new(oauth,
      oauth_controller.session[:oauth_request_token],
      oauth_controller.session[:oauth_request_token_secret])
    end
    
    def generate_access_token
      request_token.get_access_token(:oauth_verifier => oauth_controller.params[:oauth_verifier])
    end
    
    def oauth_response
      oauth_controller.params && oauth_controller.params[:oauth_token]
    end
    
    def oauth_controller
      is_auth_session? ? controller : session_class.controller
    end
    
    def oauth
      is_auth_session? ? self.class.oauth_consumer : session_class.oauth_consumer
    end
    
    def is_auth_session?
      self.is_a?(Authlogic::Session::Base)
    end
    
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
authlogic-oauth-1.0.2 lib/authlogic_oauth/oauth_process.rb
authlogic-oauth-1.0.3 lib/authlogic_oauth/oauth_process.rb
authlogic-oauth-1.0.4 lib/authlogic_oauth/oauth_process.rb
authlogic-oauth-1.0.5 lib/authlogic_oauth/oauth_process.rb
authlogic-oauth-1.0.6 lib/authlogic_oauth/oauth_process.rb
authlogic-oauth-1.0.7 lib/authlogic_oauth/oauth_process.rb