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

Pop identity_id if saving user and the ID is an empty string #1104

Merged
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
12 changes: 10 additions & 2 deletions assemblyline_ui/api/v4/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def add_user_account(username, **_):
}
"""

data = request.json
data: dict = request.json

if "{" in username or "}" in username:
return make_api_response({"success": False}, "You can't use '{}' in the username", 412)
Expand All @@ -353,6 +353,10 @@ def add_user_account(username, **_):
# Clear non user account data
avatar = data.pop('avatar', None)

# Check identity_id value
if not data.get('identity_id'):
data.pop('identity_id')

if avatar is not None:
STORAGE.user_avatar.save(username, avatar)

Expand Down Expand Up @@ -492,7 +496,7 @@ def set_user_account(username, **kwargs):
}
"""
try:
data = request.json
data: dict = request.json
new_pass = data.pop('new_pass', None)

old_user = STORAGE.user.get(username, as_obj=False)
Expand All @@ -519,6 +523,10 @@ def set_user_account(username, **kwargs):
# Apply dynamic classification
data['classification'] = get_dynamic_classification(data['classification'], data)

# Check identity_id value
if not data.get('identity_id'):
data.pop('identity_id')

ret_val = save_user_account(username, data, kwargs['user'])

if ret_val and \
Expand Down