special_character.rb 478 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class PasswordPolicy
  3. class SpecialCharacter < PasswordPolicy::Backend
  4. NEED_SPECIAL_CHARACTER_REGEXP = %r{\W}
  5. def valid?
  6. @password.match? NEED_SPECIAL_CHARACTER_REGEXP
  7. end
  8. def error
  9. [__('Invalid password, it must contain at least 1 special character!')]
  10. end
  11. def self.applicable?
  12. Setting.get('password_need_special_character').to_i == 1
  13. end
  14. end
  15. end