Skip to content

Commit

Permalink
#597 All handle queries will be case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
eljeffeg committed Nov 9, 2023
1 parent 06fae9f commit 64f37a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion handlers/PublicHandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def form_validation(self):
):
raise ValidationError("Invalid Team Motto format")
if (
User.by_handle(self.get_argument("handle", ""), case_sensitive=False)
User.by_handle(self.get_argument("handle", ""))
is not None
):
raise ValidationError("This handle is already registered")
Expand Down
10 changes: 5 additions & 5 deletions models/User.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,17 @@ def by_email(cls, email):
return None

@classmethod
def by_handle(cls, handle, case_sensitive=True):
def by_handle(cls, handle):
"""Return the user object whose user is "_handle" """
handle = str(handle).strip()
if case_sensitive:
return dbsession.query(cls).filter_by(_handle=handle).first()
else:
if handle and len(handle) > 0:
handle = str(handle).strip()
return (
dbsession.query(cls)
.filter(func.lower(User._handle) == func.lower(handle))
.first()
)
else:
return None

@classmethod
def _hash_bank_password(cls, algorithm_name, password):
Expand Down

0 comments on commit 64f37a9

Please sign in to comment.