Skip to content

Commit

Permalink
Merge pull request #11775 from rtibbles/exceptional_auth
Browse files Browse the repository at this point in the history
Properly handle list shaped details.
  • Loading branch information
marcellamaki authored Jan 23, 2024
2 parents a9fbc6b + b000707 commit 6b8acac
Showing 1 changed file with 8 additions and 3 deletions.
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

0 comments on commit 6b8acac

Please sign in to comment.