Module: Authentasaurus::Ar::ActsAsAuthenticatable::InstanceMethods

Defined in:
lib/authentasaurus/ar/acts_as_authenticatable.rb

Instance Method Summary collapse

Instance Method Details

#activateObject



83
84
85
# File 'lib/authentasaurus/ar/acts_as_authenticatable.rb', line 83

def activate
  self.update_attribute :active, true
end

#create_remember_me_tokenObject



91
92
93
94
95
# File 'lib/authentasaurus/ar/acts_as_authenticatable.rb', line 91

def create_remember_me_token
  pass_to_hash=Time.now.to_i.to_s + "Securasaurus" + password_seed
  self.update_attribute :remember_me_token, Digest::SHA1.hexdigest(pass_to_hash)
  self.remember_me_token
end

#deactivateObject



87
88
89
# File 'lib/authentasaurus/ar/acts_as_authenticatable.rb', line 87

def deactivate
  self.update_attribute :active, false
end

#new_passwordObject

New password attribute (used when editing a user)



72
73
74
# File 'lib/authentasaurus/ar/acts_as_authenticatable.rb', line 72

def new_password
  return @new_password
end

#new_password=(pwd) ⇒ Object



76
77
78
79
80
81
# File 'lib/authentasaurus/ar/acts_as_authenticatable.rb', line 76

def new_password=(pwd)
  @new_password = pwd
  return if pwd.blank?
  create_salt
  self.hashed_password = self.class.encrypt_password(@new_password, self.password_seed)
end

#passwordObject

Password attribute (used when creating a user)



60
61
62
# File 'lib/authentasaurus/ar/acts_as_authenticatable.rb', line 60

def password
  return @password
end

#password=(pwd) ⇒ Object



64
65
66
67
68
69
# File 'lib/authentasaurus/ar/acts_as_authenticatable.rb', line 64

def password=(pwd)
  @password = pwd
  return if pwd.blank?
  create_salt
  self.hashed_password = self.class.encrypt_password(@password, self.password_seed)
end

#username=(username) ⇒ Object



55
56
57
# File 'lib/authentasaurus/ar/acts_as_authenticatable.rb', line 55

def username=(username)      
  super(username.downcase)
end