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

Properly handle list shaped details. #11775

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
11 changes: 8 additions & 3 deletions kolibri/plugins/user_profile/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ def validate(self, data):
try:
job_data = super(MergeUserValidator, self).validate(data)
except ValidationError as e:
if e.detail.code == error_constants.AUTHENTICATION_FAILED:
self.create_remote_user(data)
job_data = super(MergeUserValidator, self).validate(data)
details = e.detail if isinstance(e.detail, list) else [e.detail]
for detail in details:
# If any of the errors are authentication related, then we need to create the user
if detail.code == error_constants.AUTHENTICATION_FAILED:
self.create_remote_user(data)
job_data = super(MergeUserValidator, self).validate(data)
break
else:
# If we didn't break out of the loop, then we need to raise the original error
raise

job_data["kwargs"]["local_user_id"] = data["local_user_id"].id
Expand Down