Normalize the email address in the same way in all places
We were case normalizing the email address for registration, but not at all for the forgotten password retrieval. Make a tools.mail.normalize_email helper that can be used to normalize the email in the same way in all places. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
0c97a82556
commit
0f9cf6ef32
@ -122,3 +122,16 @@ def send_email(from_addr, to_addrs, subject, message_body):
|
||||
print message.get_payload(decode=True)
|
||||
|
||||
return mhost.sendmail(from_addr, to_addrs, message.as_string())
|
||||
|
||||
|
||||
def normalize_email(email):
|
||||
"""return case sensitive part, lower case domain name
|
||||
|
||||
:returns: None in case of broken email addresses"""
|
||||
try:
|
||||
em_user, em_dom = email.split('@', 1)
|
||||
except ValueError:
|
||||
# email contained no '@'
|
||||
return None
|
||||
email = "@".join((em_user, em_dom.lower()))
|
||||
return email
|
||||
|
Loading…
x
Reference in New Issue
Block a user