From 453d141f27c4b100f3a4222c6c2780fba6757452 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Mon, 27 Nov 2017 21:32:46 +0100 Subject: [PATCH] [FIX] Underscore is a special character --- password_security/__openerp__.py | 2 +- password_security/models/res_users.py | 2 +- password_security/tests/test_res_users.py | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/password_security/__openerp__.py b/password_security/__openerp__.py index 814026374..7992f205b 100644 --- a/password_security/__openerp__.py +++ b/password_security/__openerp__.py @@ -5,7 +5,7 @@ 'name': 'Password Security', "summary": "Allow admin to set password security requirements.", - 'version': '8.0.1.1.0', + 'version': '8.0.1.1.1', 'author': "LasLabs, Odoo Community Association (OCA)", 'category': 'Base', 'depends': [ diff --git a/password_security/models/res_users.py b/password_security/models/res_users.py index 63b1fb3d6..1b319ea44 100644 --- a/password_security/models/res_users.py +++ b/password_security/models/res_users.py @@ -78,7 +78,7 @@ class ResUsers(models.Model): if company_id.password_numeric: password_regex.append(r'(?=.*?\d)') if company_id.password_special: - password_regex.append(r'(?=.*?\W)') + password_regex.append(r'(?=.*?[\W_])') password_regex.append('.{%d,}$' % company_id.password_length) if not re.search(''.join(password_regex), password): raise PassError(_(self.password_match_message())) diff --git a/password_security/tests/test_res_users.py b/password_security/tests/test_res_users.py index 4d43130ee..fe6e46bdc 100644 --- a/password_security/tests/test_res_users.py +++ b/password_security/tests/test_res_users.py @@ -155,3 +155,8 @@ class TestResUsers(TransactionCase): self.assertEqual( True, rec_id._validate_pass_reset(), ) + + def test_underscore_is_special_character(self): + self.assertTrue(self.main_comp.password_special) + rec_id = self._new_record() + rec_id.check_password('asdQWE12345_3')