Posted By


winson on 04/30/07

Tagged


Statistics


Viewed 895 times
Favorited by 1 user(s)

Basic authenticate


/ Published in: Rails
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.