Module: AuthlogicConnect::Oauth::State

Included in:
Variables
Defined in:
lib/authlogic_connect/oauth/state.rb

Overview

all these methods must return true or false

Instance Method Summary collapse

Instance Method Details

#allow_oauth_redirect?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/authlogic_connect/oauth/state.rb', line 40

def allow_oauth_redirect?
  authenticating_with_oauth? && !oauth_complete?
end

#authenticating_with_oauth?Boolean

main method we call on validation

Returns:

  • (Boolean)


36
37
38
# File 'lib/authlogic_connect/oauth/state.rb', line 36

def authenticating_with_oauth?
  correct_request_class? && using_oauth?
end

#complete_oauth?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/authlogic_connect/oauth/state.rb', line 48

def complete_oauth?
  using_oauth? && !new_oauth_request?
end

#new_oauth_request?Boolean

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/authlogic_connect/oauth/state.rb', line 26

def new_oauth_request?
  return false if stored_oauth_token_and_secret?
  return oauth_response.blank?
end

#oauth_complete?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/authlogic_connect/oauth/state.rb', line 17

def oauth_complete?
  oauth_response? || stored_oauth_token_and_secret?
end

#oauth_provider?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/authlogic_connect/oauth/state.rb', line 31

def oauth_provider?
  !oauth_provider.blank?
end

#oauth_request?Boolean

  1. to call

checks that we just passed parameters to it, and that the parameters say ‘authentication_method’ == ‘oauth’

Returns:

  • (Boolean)


7
8
9
# File 'lib/authlogic_connect/oauth/state.rb', line 7

def oauth_request?
  auth_params? && oauth_provider?
end

#oauth_response?Boolean

  1. from call

checks that the correct session variables are there

Returns:

  • (Boolean)


13
14
15
# File 'lib/authlogic_connect/oauth/state.rb', line 13

def oauth_response?
  !oauth_response.nil? && !auth_session.nil? && auth_session[:auth_request_class] == self.class.name && auth_session[:auth_method] == "oauth"
end

#start_oauth?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/authlogic_connect/oauth/state.rb', line 44

def start_oauth?
  authenticating_with_oauth? && !oauth_complete?
end

#stored_oauth_token_and_secret?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/authlogic_connect/oauth/state.rb', line 56

def stored_oauth_token_and_secret?
  !is_auth_session? && auth_params && auth_params.has_key?(:_key) && auth_params.has_key?(:_token) && auth_params.has_key?(:_secret)
end

#using_oauth?Boolean

  1. either to or from call

Returns:

  • (Boolean)


22
23
24
# File 'lib/authlogic_connect/oauth/state.rb', line 22

def using_oauth?
  oauth_request? || oauth_response? || stored_oauth_token_and_secret?
end

#validate_password_with_oauth?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/authlogic_connect/oauth/state.rb', line 52

def validate_password_with_oauth?
  !using_oauth? && require_password?
end