Sha256: f3575bae994bcc1289bfa379cdffaaed8a18241033e0b9f20f4dfd6c69d574b7

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

# all these methods must return true or false
module AuthlogicConnect::Oauth::State
  
  # 1. to call
  # checks that we just passed parameters to it,
  # and that the parameters say 'authentication_method' == 'oauth'
  def oauth_request?
    !auth_params.nil? && oauth_provider?
  end
  
  # 2. from call
  # checks that the correct session variables are there
  def oauth_response?
    !oauth_response.nil? && !auth_session.nil? && auth_session[:auth_request_class] == self.class.name && auth_session[:auth_method] == "oauth"
  end
  alias_method :oauth_complete?, :oauth_response?
  
  # 3. either to or from call
  def using_oauth?
    oauth_request? || oauth_response?
  end
  
  def new_oauth_request?
    oauth_response.blank?
  end
  
  def oauth_provider?
    !oauth_provider.nil? && !oauth_provider.empty?
  end
  
  # main method we call on validation
  def authenticating_with_oauth?
    correct_request_class? && using_oauth?
  end
  
  def allow_oauth_redirect?
    authenticating_with_oauth? && !oauth_complete?
  end
  
  # both checks if it can redirect, and does the redirect.
  # is there a more concise way to do this?
  def redirecting_to_oauth_server?
    if allow_oauth_redirect?
      redirect_to_oauth
      return true
    end
    return false
  end
  
  def validate_password_with_oauth?
    !using_oauth? && require_password?
  end
  
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
lsdr-authlogic-connect-0.0.3.9 lib/authlogic_connect/oauth/state.rb
authlogic-connect-0.0.3.9 lib/authlogic_connect/oauth/state.rb
authlogic-connect-0.0.3.8 lib/authlogic_connect/oauth/state.rb
authlogic-connect-0.0.3.6 lib/authlogic_connect/oauth/state.rb