2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2020-08-28 14:07:30 +00:00
|
|
|
class PasswordPolicy
|
|
|
|
class Digit < PasswordPolicy::Backend
|
|
|
|
|
2021-05-12 11:37:44 +00:00
|
|
|
NEED_DIGIT_REGEXP = %r{\d}.freeze
|
2020-08-28 14:07:30 +00:00
|
|
|
|
|
|
|
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
|