trabajo-afectivo/lib/password_policy/special_character.rb

21 lines
485 B
Ruby
Raw Permalink Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
class PasswordPolicy
class SpecialCharacter < PasswordPolicy::Backend
NEED_SPECIAL_CHARACTER_REGEXP = %r{\W}.freeze
def valid?
@password.match? NEED_SPECIAL_CHARACTER_REGEXP
end
def error
[__('Invalid password, it must contain at least 1 special character!')]
end
def self.applicable?
Setting.get('password_need_special_character').to_i == 1
end
end
end