Browse Source

Merge pull request #1077 from StefanRijnhart/fix/10.0/password_security/underscore

[FIX] Underscore is a special character
pull/1084/head
Pedro M. Baeza 7 years ago
committed by GitHub
parent
commit
5bf89f45ba
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      password_security/__manifest__.py
  2. 2
      password_security/models/res_users.py
  3. 5
      password_security/tests/test_res_users.py

2
password_security/__manifest__.py

@ -5,7 +5,7 @@
'name': 'Password Security', 'name': 'Password Security',
"summary": "Allow admin to set password security requirements.", "summary": "Allow admin to set password security requirements.",
'version': '10.0.1.1.0',
'version': '10.0.1.1.1',
'author': "LasLabs, Odoo Community Association (OCA)", 'author': "LasLabs, Odoo Community Association (OCA)",
'category': 'Base', 'category': 'Base',
'depends': [ 'depends': [

2
password_security/models/res_users.py

@ -84,7 +84,7 @@ class ResUsers(models.Model):
if company_id.password_numeric: if company_id.password_numeric:
password_regex.append(r'(?=.*?\d)') password_regex.append(r'(?=.*?\d)')
if company_id.password_special: if company_id.password_special:
password_regex.append(r'(?=.*?\W)')
password_regex.append(r'(?=.*?[\W_])')
password_regex.append('.{%d,}$' % company_id.password_length) password_regex.append('.{%d,}$' % company_id.password_length)
if not re.search(''.join(password_regex), password): if not re.search(''.join(password_regex), password):
raise PassError(self.password_match_message()) raise PassError(self.password_match_message())

5
password_security/tests/test_res_users.py

@ -159,3 +159,8 @@ class TestResUsers(TransactionCase):
self.assertEqual( self.assertEqual(
True, rec_id._validate_pass_reset(), 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')
Loading…
Cancel
Save