trabajo-afectivo/lib/password_policy/digit.rb

21 lines
426 B
Ruby
Raw Normal View History

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