2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2020-08-28 14:07:30 +00:00
|
|
|
class PasswordPolicy
|
|
|
|
class SpecialCharacter < PasswordPolicy::Backend
|
|
|
|
|
2021-05-12 11:37:44 +00:00
|
|
|
NEED_SPECIAL_CHARACTER_REGEXP = %r{\W}.freeze
|
2020-08-28 14:07:30 +00:00
|
|
|
|
|
|
|
def valid?
|
|
|
|
@password.match? NEED_SPECIAL_CHARACTER_REGEXP
|
|
|
|
end
|
|
|
|
|
|
|
|
def error
|
2021-11-15 15:58:19 +00:00
|
|
|
[__('Invalid password, it must contain at least 1 special character!')]
|
2020-08-28 14:07:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.applicable?
|
|
|
|
Setting.get('password_need_special_character').to_i == 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|