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.
- #create_oauth_token ⇒ 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
#authenticate_with_oauth, #cleanup_oauth_session, #redirect_to_oauth, #save_auth_session_token, #validate_by_oauth
Methods included from Variables
#oauth_consumer, #oauth_provider, #oauth_response, #oauth_token, #oauth_token_and_secret, #oauth_variables, #oauth_version, #token_class
Methods included from State
#allow_oauth_redirect?, #authenticating_with_oauth?, #new_oauth_request?, #oauth_provider?, #oauth_request?, #oauth_response?, #redirecting_to_oauth_server?, #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 30 31 |
# 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 # email needs to be optional for oauth base.validate_email_field = false 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.
49 50 51 52 53 |
# File 'lib/authlogic_connect/oauth/user.rb', line 49 def complete_oauth_transaction unless create_oauth_token self.errors.add(:tokens, "you have already created an account using your #{token_class.service_name} account, so it") end end |
#create_oauth_token ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/authlogic_connect/oauth/user.rb', line 55 def create_oauth_token token = token_class.new(oauth_token_and_secret) if has_token?(oauth_provider) || Token.find_by_key(token.key) || Token.find_by_token(token.token) return false else self.tokens << token self.active_token = token return true end end |
#restore_attributes ⇒ Object
40 41 42 43 |
# File 'lib/authlogic_connect/oauth/user.rb', line 40 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
35 36 37 38 |
# File 'lib/authlogic_connect/oauth/user.rb', line 35 def save_oauth_session super auth_session[:auth_attributes] = attributes.reject!{|k, v| v.blank?} unless is_auth_session? end |