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)


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

def allow_oauth_redirect?
  authenticating_with_oauth? && !oauth_complete?
end

#authenticating_with_oauth?Boolean

main method we call on validation

Returns:

  • (Boolean)


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

def authenticating_with_oauth?
  correct_request_class? && using_oauth?
end

#new_oauth_request?Boolean

Returns:

  • (Boolean)


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

def new_oauth_request?
  oauth_response.blank?
end

#oauth_provider?Boolean

Returns:

  • (Boolean)


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

def oauth_provider?
  !oauth_provider.nil? && !oauth_provider.empty?
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.nil? && oauth_provider?
end

#oauth_response?Boolean Also known as: oauth_complete?

  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

#redirecting_to_oauth_server?Boolean

both checks if it can redirect, and does the redirect. is there a more concise way to do this?

Returns:

  • (Boolean)


42
43
44
45
46
47
48
# File 'lib/authlogic_connect/oauth/state.rb', line 42

def redirecting_to_oauth_server?
  if allow_oauth_redirect?
    redirect_to_oauth
    return true
  end
  return false
end

#using_oauth?Boolean

  1. either to or from call

Returns:

  • (Boolean)


19
20
21
# File 'lib/authlogic_connect/oauth/state.rb', line 19

def using_oauth?
  oauth_request? || oauth_response?
end

#validate_password_with_oauth?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/authlogic_connect/oauth/state.rb', line 50

def validate_password_with_oauth?
  !using_oauth? && require_password?
end