Module: AuthlogicOauth::ActsAsAuthentic::Methods
- Includes:
- OauthProcess
- Defined in:
- lib/authlogic_oauth/acts_as_authentic.rb
Class Method Summary collapse
-
.included(klass) ⇒ Object
Set up some simple validations.
Instance Method Summary collapse
- #oauth_secret ⇒ Object
- #oauth_secret=(value) ⇒ Object
-
#oauth_token ⇒ Object
accessors for oauth fields.
- #oauth_token=(value) ⇒ Object
- #save(perform_validation = {:validate=>true}) {|result| ... } ⇒ Object
Class Method Details
.included(klass) ⇒ Object
Set up some simple validations
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/authlogic_oauth/acts_as_authentic.rb', line 34 def self.included(klass) klass.class_eval do alias_method "#{oauth_token_field.to_s}=".to_sym, :oauth_token= alias_method "#{oauth_secret_field.to_s}=".to_sym, :oauth_secret= end return if !klass.column_names.include?(klass.oauth_token_field.to_s) klass.class_eval do validate :validate_by_oauth, :if => :authenticating_with_oauth? validates_uniqueness_of klass.oauth_token_field, :scope => validations_scope, :if => :using_oauth? validates_presence_of klass.oauth_secret_field, :scope => validations_scope, :if => :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 klass.validate_email_field = false end |
Instance Method Details
#oauth_secret ⇒ Object
81 82 83 |
# File 'lib/authlogic_oauth/acts_as_authentic.rb', line 81 def oauth_secret read_attribute(oauth_secret_field) end |
#oauth_secret=(value) ⇒ Object
85 86 87 |
# File 'lib/authlogic_oauth/acts_as_authentic.rb', line 85 def oauth_secret=(value) write_attribute(oauth_secret_field, value.blank? ? nil : value) end |
#oauth_token ⇒ Object
accessors for oauth fields
73 74 75 |
# File 'lib/authlogic_oauth/acts_as_authentic.rb', line 73 def oauth_token read_attribute(oauth_token_field) end |
#oauth_token=(value) ⇒ Object
77 78 79 |
# File 'lib/authlogic_oauth/acts_as_authentic.rb', line 77 def oauth_token=(value) write_attribute(oauth_token_field, value.blank? ? nil : value) end |
#save(perform_validation = {:validate=>true}) {|result| ... } ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/authlogic_oauth/acts_as_authentic.rb', line 59 def save(perform_validation={:validate=>true}, &block) if perform_validation[:validate] && block_given? && redirecting_to_oauth_server? # Save attributes so they aren't lost during the authentication with the oauth server session_class.controller.session[:authlogic_oauth_attributes] = attributes.reject!{|k, v| v.blank?} redirect_to_oauth return false end result = super yield(result) if block_given? result end |