Skip to content

Commit

Permalink
New Password Validator
Browse files Browse the repository at this point in the history
  • Loading branch information
nasief committed May 24, 2018
1 parent 21b77b4 commit 55a21ee
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions accountsplus/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,16 @@ def validate(self, password, user=None):
def get_help_text(self):
return _('Password should contain uppercase, lowercase, numeric values and at least '
'one of the following $@#!%*?&')


class CustomPasswordValidator(object):

def validate(self, password, user=None):
regex = '(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[A-Za-z\d$@#!%*\?&`+-_^/]'
if not re.match(regex, password):
raise ValidationError(_('Password should contain uppercase, lowercase, numeric values and at least '
'one of the following $@#!%*?&'), code='password_is_weak')

def get_help_text(self):
return _('Password should contain uppercase, lowercase, numeric values and at least '
'one of the following $@#!%*?&')

0 comments on commit 55a21ee

Please sign in to comment.