2020-08-28 14:07:30 +00:00
|
|
|
class PasswordPolicy
|
|
|
|
class UpperAndLowerCaseCharacters < PasswordPolicy::Backend
|
|
|
|
|
2021-05-12 11:37:44 +00:00
|
|
|
UPPER_LOWER_REGEXPS = [%r{\p{Upper}.*\p{Upper}}, %r{\p{Lower}.*\p{Lower}}].freeze
|
2020-08-28 14:07:30 +00:00
|
|
|
|
|
|
|
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
|