Posted By

winson on 04/30/07


Tagged

login textmate model


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

webstic
octoberborn


Basic authenticate


 / Published in: Rails
 

  1. def self.authenticate(email, password)
  2. user = find(:first, :conditions => ['email = ?', email])
  3. unless user.blank?
  4. if user.password_hash.nil? or Digest::SHA256.hexdigest(password + user.password_salt) == user.password_hash
  5. user.update_attributes(:last_login => Time.now.to_s(:db))
  6. user
  7. else
  8. raise AuthenticationError, "Invalid email and/or password"
  9. end
  10. else
  11. raise AuthenticationError, "Invalid email and/or password"
  12. end
  13. end

Report this snippet  

You need to login to post a comment.