internal.rb 477 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
  2. module Auth::Internal
  3. def self.check( username, password, config, user )
  4. # return if no user exists
  5. return nil if !user
  6. # sha auth check
  7. if user.password =~ /^\{sha2\}/
  8. crypted = Digest::SHA2.hexdigest( password )
  9. return user if user.password == "{sha2}#{crypted}"
  10. end
  11. # plain auth check
  12. return user if user.password == password
  13. return false
  14. end
  15. end