trabajo-afectivo/lib/password_policy/upper_and_lower_case_characters.rb
2022-01-01 14:38:12 +01:00

20 lines
575 B
Ruby

# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
class PasswordPolicy
class UpperAndLowerCaseCharacters < PasswordPolicy::Backend
UPPER_LOWER_REGEXPS = [%r{\p{Upper}.*\p{Upper}}, %r{\p{Lower}.*\p{Lower}}].freeze
def valid?
UPPER_LOWER_REGEXPS.all? { |regexp| @password.match?(regexp) }
end
def error
[__('Invalid password, it must contain at least 2 lowercase and 2 uppercase characters!')]
end
def self.applicable?
Setting.get('password_min_2_lower_2_upper_characters').to_i == 1
end
end
end