I use some code like this:

  attr_accessor :new_password

  validates_presence_of :new_password, :on => :create
  validates_length_of :new_password, :minimum => 6, :allow_nil =>
true, :allow_blank => true, :unless => :new_password.blank?
  validates_confirmation_of :new_password

  before_save :set_encrypted_password

  def set_encrypted_password
    write_attribute(:password, Client.encrypt_password(@new_password))
unless @new_password.nil? || @new_password.blank?
  end

  def self.encrypt_password(password)
    Digest::SHA1.hexdigest("something_random_goes_here_#{password}")
  end

  def self.authenticate(email, password)
    find_by_email_and_password_and_active(email, encrypt_password
(password), true)
  end

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to