Add checks for username and passwords, move checks to model.
This commit is contained in:
parent
1574be3c07
commit
87dc3b6344
3 changed files with 27 additions and 6 deletions
|
@ -1,7 +1,21 @@
|
|||
import re
|
||||
import urllib
|
||||
|
||||
|
||||
def validate_email(email_address):
|
||||
if re.match(r'[^@]+@[^@]+\.[^@]+', email_address):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def validate_username(username):
|
||||
# Minimum length of 2, maximum length of 255, no url unsafe characters
|
||||
return (urllib.quote(username, safe='') == username and
|
||||
len(username) > 1 and
|
||||
len(username) < 256)
|
||||
|
||||
def validate_password(password):
|
||||
# No whitespace and minimum length of 8
|
||||
if re.search(r'\s', password):
|
||||
return False
|
||||
return len(password) > 7
|
||||
|
|
Reference in a new issue