internal.rb 714 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. class Auth
  3. class Internal < Auth::Base
  4. def valid?(user, password)
  5. return false if user.blank?
  6. if PasswordHash.legacy?(user.password, password)
  7. update_password(user, password)
  8. return true
  9. end
  10. password_verified = PasswordHash.verified?(user.password, password)
  11. raise Exceptions::NotAuthorized, 'Please verify your account before you can login!' if !user.verified && user.source == 'signup' && password_verified
  12. password_verified
  13. end
  14. private
  15. def update_password(user, password)
  16. user.password = PasswordHash.crypt(password)
  17. user.save
  18. end
  19. end
  20. end