Fix ORCID login when no family name was given #914
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Handle the case where the user has not registered a
family-name
and ORCID returnsNone
.Proposed changes
This addresses python-social-auth/social-app-django#355 and #602 (which it appears to duplicate). Full credit to paloha, who very clearly explained the issue and proposed the simple fix included here.
As a brief summary: ORCID does not require users to enter a family name and returns a
family-name
key with valueNone
in this case. The code expects that key to either be absent, or contain a dictionary. This leads to anAttributeError
after successful login by a user who has not provided a family name to ORCID.I considered adding a test case to cover this scenario, but it looks like the testing infrastructure is only set up for a single possible
user_data_body
? Please let me know if I have missed an easy and obvious way to add a test for an additional case of returned data. The change does resolve the issue in my manual testing.Types of changes
Please check the type of change your PR introduces:
Checklist
Put an
x
in the boxes that apply. You can also fill these out after creatingthe PR. If you're unsure about any of them, don't hesitate to ask. We're here to
help! This is simply a reminder of what we are going to look for before merging
your code.
Other information
Any other information that is important to this PR such as screenshots of how
the component looks before and after the change.