Module: AuthlogicOauth2::ActsAsAuthentic::Methods
- Includes:
- Oauth2Process
- Defined in:
- lib/authlogic_oauth2/acts_as_authentic.rb
Class Method Summary collapse
-
.included(klass) ⇒ Object
Set up some simple validations.
Instance Method Summary collapse
-
#oauth2_access ⇒ Object
Provides access to an API exposed on the access_token object.
-
#oauth2_token ⇒ Object
Accessors for oauth2 fields.
- #oauth2_token=(value) ⇒ Object
- #save(perform_validation = true) {|result| ... } ⇒ Object
Class Method Details
.included(klass) ⇒ Object
Set up some simple validations
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/authlogic_oauth2/acts_as_authentic.rb', line 27 def self.included(klass) klass.class_eval do alias_method "#{oauth2_token_field.to_s}=".to_sym, :oauth2_token= end return if !klass.column_names.include?(klass.oauth2_token_field.to_s) klass.class_eval do validate :validate_by_oauth2, :if => :authenticating_with_oauth2? validates_uniqueness_of klass.oauth2_token_field, :scope => validations_scope, :if => :using_oauth2? .merge(:if => :validate_password_with_oauth2?) .merge(:if => :validate_password_with_oauth2?) .merge(:if => :validate_password_with_oauth2?) .merge(:if => :validate_password_with_oauth2?) .merge(:if => :validate_password_with_oauth2?) end # email needs to be optional for oauth2 klass.validate_email_field = false end |
Instance Method Details
#oauth2_access ⇒ Object
Provides access to an API exposed on the access_token object
73 74 75 |
# File 'lib/authlogic_oauth2/acts_as_authentic.rb', line 73 def oauth2_access access_token end |
#oauth2_token ⇒ Object
Accessors for oauth2 fields
64 65 66 |
# File 'lib/authlogic_oauth2/acts_as_authentic.rb', line 64 def oauth2_token read_attribute(oauth2_token_field) end |
#oauth2_token=(value) ⇒ Object
68 69 70 |
# File 'lib/authlogic_oauth2/acts_as_authentic.rb', line 68 def oauth2_token=(value) write_attribute(oauth2_token_field, value.blank? ? nil : value) end |
#save(perform_validation = true) {|result| ... } ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/authlogic_oauth2/acts_as_authentic.rb', line 50 def save(perform_validation = true, &block) if perform_validation && block_given? && redirecting_to_oauth2_server? # Save attributes so they aren't lost during the authentication with the oauth2 server session_class.controller.session[:authlogic_oauth2_attributes] = attributes.reject!{|k, v| v.blank?} redirect_to_oauth2 return false end result = super yield(result) if block_given? result end |