Return to Snippet

Revision: 2857
at April 30, 2007 00:34 by winson


Updated Code
def self.authenticate(email, password)
  user = find(:first, :conditions => ['email = ?', email])
  unless user.blank?
    if user.password_hash.nil? or Digest::SHA256.hexdigest(password + user.password_salt) == user.password_hash
      user.update_attributes(:last_login => Time.now.to_s(:db))
      user
    else
      raise AuthenticationError, "Invalid email and/or password"
    end
  else
    raise AuthenticationError, "Invalid email and/or password"
  end
end

Revision: 2856
at April 30, 2007 00:33 by winson


Initial Code
def self.authenticate(email, password)
  user = find(:first, :conditions => ['email = ?', email])
  unless user.blank?
    if user.password_hash.nil? or Digest::SHA256.hexdigest(password + user.password_salt) == user.password_hash
      user.update_attributes(:last_login => Time.now.to_s(:db))
      user
    else
      raise AuthenticationError, "Invalid email and/or password"
    end
  else
    raise AuthenticationError, "Invalid email and/or password"
  end
end

Initial URL


Initial Description


Initial Title
Basic authenticate

Initial Tags
login, textmate

Initial Language
Rails