Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate user handle with lowercase #4540

Merged
merged 1 commit into from
Dec 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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