Module: AuthlogicRpx::ActsAsAuthentic::Methods

Defined in:
lib/authlogic_rpx/acts_as_authentic.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

Set up some simple validations



33
34
35
36
37
38
39
40
41
42
# File 'lib/authlogic_rpx/acts_as_authentic.rb', line 33

def self.included(klass)
	klass.class_eval do
		validates_uniqueness_of :rpx_identifier, :scope => validations_scope, :if => :using_rpx?
		validates_length_of_password_field_options validates_length_of_password_field_options.merge(:if => :validate_password_with_rpx?)
		validates_confirmation_of_password_field_options validates_confirmation_of_password_field_options.merge(:if => :validate_password_with_rpx?)
		validates_length_of_password_confirmation_field_options validates_length_of_password_confirmation_field_options.merge(:if => :validate_password_with_rpx?)
		before_validation :adding_rpx_identifier
		after_create :map_rpx_identifier
	end
end

Instance Method Details

#save(perform_validation = true) {|result| ... } ⇒ Object

support a block given to the save

Yields:

  • (result)


45
46
47
48
49
# File 'lib/authlogic_rpx/acts_as_authentic.rb', line 45

def save(perform_validation = true, &block)
	result = super perform_validation
	yield(result) if block_given?
	result
end

#using_password?Boolean

test if account it using normal password authentication

Returns:

  • (Boolean)


57
58
59
# File 'lib/authlogic_rpx/acts_as_authentic.rb', line 57

def using_password?
	!send(crypted_password_field).blank?
end

#using_rpx?Boolean

test if account it using RPX authentication

Returns:

  • (Boolean)


52
53
54
# File 'lib/authlogic_rpx/acts_as_authentic.rb', line 52

def using_rpx?
  self.column_names.include?("rpx_identifier") || !rpx_identifier.blank?
end