password_check.rb 432 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Service::User::PasswordCheck < Service::Base
  3. attr_reader :user, :password
  4. def initialize(user:, password:)
  5. super()
  6. @user = user
  7. @password = password
  8. end
  9. def execute
  10. Auth
  11. .new(user.login, password, only_verify_password: true)
  12. .valid!
  13. true
  14. rescue Auth::Error::AuthenticationFailed
  15. false
  16. end
  17. end