Module: Merb::Authentication::Mixins::SaltedUserWithAccount

Defined in:
lib/heedley-merb-auth-with-account/mixins/salted_user.rb,
lib/heedley-merb-auth-with-account/mixins/salted_user/dm_salted_user_with_account.rb

Overview

This mixin provides basic salted user password encryption.

Added properties:

:crypted_password, String
:salt,             String

To use it simply require it and include it into your user class.

class User

include Merb::Authentication::Mixins::SaltedUser

end

Defined Under Namespace

Modules: ClassMethods, DMClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/heedley-merb-auth-with-account/mixins/salted_user.rb', line 21

def self.included(base)
  base.class_eval do 
    attr_accessor :password, :password_confirmation
    
    include Merb::Authentication::Mixins::SaltedUserWithAccount::InstanceMethods
    extend  Merb::Authentication::Mixins::SaltedUserWithAccount::ClassMethods
    
    path = File.expand_path(File.dirname(__FILE__)) / "salted_user"
    if defined?(DataMapper) && DataMapper::Resource > self
      p "require: " + path / "dm_salted_user_with_account"
      require path / "dm_salted_user_with_account"
      extend(Merb::Authentication::Mixins::SaltedUserWithAccount::DMClassMethods)
    elsif defined?(ActiveRecord) && ancestors.include?(ActiveRecord::Base)
      require path / "ar_salted_user_with_account"
      extend(Merb::Authentication::Mixins::SaltedUserWithAccount::ARClassMethods)
    elsif defined?(Sequel) && ancestors.include?(Sequel::Model)
      require path / "sq_salted_user_with_account"
      extend(Merb::Authentication::Mixins::SaltedUserWithAccount::SQClassMethods)
    elsif defined?(RelaxDB) && ancestors.include?(RelaxDB::Document)
      require path / "relaxdb_salted_user_with_account"
      extend(Merb::Authentication::Mixins::SaltedUserWithAccount::RDBClassMethods)
    end
    
  end # base.class_eval
end