Skip to content

Commit

Permalink
email addres now case-insensitive when logging in; fixes #776
Browse files Browse the repository at this point in the history
  • Loading branch information
thomiel committed Nov 13, 2018
1 parent 23c61e3 commit 0bb95eb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions collecting_society_portal/models/web_user.py
Expand Up @@ -124,7 +124,15 @@ def authenticate(cls, email, password):
obj (web.user): Web user.
None: If authentication check failed.
"""
return cls.get().authenticate(email, password)

# code copied from ado/src/web_user/user.py and
# modified to support case-insensitive email addresses
users = cls.get().search([('email', 'ilike', cls.escape(email))])
if not users:
return
user, = users
if cls.get().check_password(password, user.password_hash):
return user

@classmethod
def search_all(cls):
Expand Down Expand Up @@ -168,7 +176,7 @@ def search_by_email(cls, email):
"""
if email is None:
return None
result = cls.get().search([('email', '=', email)])
result = cls.get().search([('email', 'ilike', cls.escape(email))])
return result[0] if result else None

@classmethod
Expand Down

0 comments on commit 0bb95eb

Please sign in to comment.