Skip to content

Commit

Permalink
validate user handle with lowercase (#4540)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacsolo committed Dec 28, 2022
1 parent 1b1b866 commit 079456b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions discovery-provider/src/tasks/entity_manager/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ def validate_user_tx(params: ManageEntityParameters):
def validate_user_metadata(session, user_record: User, user_metadata: Dict):
# If the user's handle is not set, validate that it is unique
if not user_record.handle:
handle_lower = user_metadata["handle"].lower()
user_handle_exists = session.query(
session.query(User).filter(User.handle == user_metadata["handle"]).exists()
session.query(User).filter(User.handle_lc == handle_lower).exists()
).scalar()
if user_handle_exists:
# Invalid user handle - should not continue to save...
raise Exception(f"User handle {user_metadata['handle']} already exists")
user_record.handle = user_metadata["handle"]
user_record.handle_lc = user_metadata["handle"].lower()
user_record.handle_lc = handle_lower

# If an artist pick track id is specified, validate that it is a valid track id
if (
Expand Down

0 comments on commit 079456b

Please sign in to comment.