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

Mix-in the required methods based on mapping mode



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/authlogic_rpx/acts_as_authentic.rb', line 82

def self.included(klass)
	klass.class_eval do
	  
	  case
	  when using_no_mapping?
	    include AuthlogicRpx::MethodSet_NoMapping
	    
       when using_internal_mapping? 
         include AuthlogicRpx::MethodSet_InternalMapping
         has_many :rpx_identifiers, :class_name => 'RPXIdentifier', :dependent => :destroy
         
     		# Add custom find_by_rpx_identifier class method
     		#
     		def self.find_by_rpx_identifier(id)
     			identifier = RPXIdentifier.find_by_identifier(id)
     			if identifier.nil?
     			  if self.column_names.include? 'rpx_identifier'
     			    # check for authentication using <=1.0.4, migrate identifier to rpx_identifiers table
     			    user = self.find( :first, :conditions => [ "rpx_identifier = ?", id ] )
     			    unless user.nil?
     			      user.add_rpx_identifier( id, 'Unknown' )
     			    end
     			    return user
     			  else
     			    return nil
     			  end
     			else
     			  identifier.send( self.methods.include?(:class_name) ? self.class_name.downcase : self.to_s.classify.downcase )
     			end
     		end
            
       else
         raise AuthlogicRpx::ActsAsAuthentic::ConfigurationError.new( "invalid or unsupported account_mapping_mode" )
       end

       # Set up some fundamental conditional validations
		validates_length_of_password_field_options validates_length_of_password_field_options.merge(:if => :validate_password_not_rpx?)
		validates_confirmation_of_password_field_options validates_confirmation_of_password_field_options.merge(:if => :validate_password_not_rpx?)
		validates_length_of_password_confirmation_field_options validates_length_of_password_confirmation_field_options.merge(:if => :validate_password_not_rpx?)
		
		before_validation :adding_rpx_identifier
	end

     # add relations and validation to RPXIdentifier based on the actual user model class name used
     #
	RPXIdentifier.class_eval do
		belongs_to klass.name.downcase.to_sym
     	validates_presence_of "#{klass.name.downcase}_id".to_sym
	end
end

Instance Method Details

#using_password?Boolean

test if account it using normal password authentication

Returns:

  • (Boolean)


134
135
136
# File 'lib/authlogic_rpx/acts_as_authentic.rb', line 134

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