Module: AuthlogicConnect::Oauth::User::InstanceMethods
- Includes:
- Process
- Defined in:
- lib/authlogic_connect/oauth/user.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
Set up some simple validations.
Instance Method Summary collapse
-
#complete_oauth_transaction ⇒ Object
single implementation method for oauth.
- #redirect_to_oauth ⇒ Object
- #restore_attributes ⇒ Object
-
#save_oauth_session ⇒ Object
user adds a few extra things to this method from Process modules work like inheritance.
Methods included from Process
#cleanup_oauth_session, #complete_oauth, #save_auth_session_token, #start_oauth, #validate_by_oauth
Methods included from Variables
#oauth_consumer, #oauth_provider, #oauth_response, #oauth_token, #oauth_token_and_secret, #oauth_variables, #oauth_version, #stored_oauth_token_and_secret, #token_class
Methods included from State
#allow_oauth_redirect?, #authenticating_with_oauth?, #complete_oauth?, #new_oauth_request?, #oauth_complete?, #oauth_provider?, #oauth_request?, #oauth_response?, #start_oauth?, #stored_oauth_token_and_secret?, #using_oauth?, #validate_password_with_oauth?
Class Method Details
.included(base) ⇒ Object
Set up some simple validations
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/authlogic_connect/oauth/user.rb', line 15 def self.included(base) base.class_eval do validate :validate_by_oauth, :if => :authenticating_with_oauth? # need these validation options if you don't want it to choke # on password length, which you don't need if you're using oauth .merge(:if => :validate_password_with_oauth?) .merge(:if => :validate_password_with_oauth?) .merge(:if => :validate_password_with_oauth?) .merge(:if => :validate_password_with_oauth?) .merge(:if => :validate_password_with_oauth?) end end |
Instance Method Details
#complete_oauth_transaction ⇒ Object
single implementation method for oauth. this is called after we get the callback url and we are saving the user to the database. it is called by the validation chain.
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/authlogic_connect/oauth/user.rb', line 51 def complete_oauth_transaction token = token_class.new(oauth_token_and_secret) old_token = token_class.find_by_key_or_token(token.key, token.token) token = old_token if old_token if has_token?(oauth_provider) self.errors.add(:tokens, "you have already created an account using your #{token_class.service_name} account, so it") else self.access_tokens << token end end |
#redirect_to_oauth ⇒ Object
38 39 40 |
# File 'lib/authlogic_connect/oauth/user.rb', line 38 def redirect_to_oauth return has_token?(oauth_provider) ? false : super end |
#restore_attributes ⇒ Object
42 43 44 45 |
# File 'lib/authlogic_connect/oauth/user.rb', line 42 def restore_attributes # Restore any attributes which were saved before redirecting to the auth server self.attributes = auth_session[:auth_attributes] end |
#save_oauth_session ⇒ Object
user adds a few extra things to this method from Process modules work like inheritance
33 34 35 36 |
# File 'lib/authlogic_connect/oauth/user.rb', line 33 def save_oauth_session super auth_session[:auth_attributes] = attributes.reject!{|k, v| v.blank? || !self.respond_to?(k)} unless is_auth_session? end |