From db50523cffb7445532503fe16d406beca17bb3fb Mon Sep 17 00:00:00 2001 From: Nikolaus Lieb <4014270+nikoder@users.noreply.github.com> Date: Wed, 15 May 2024 18:01:35 +0800 Subject: [PATCH] Fix social-app-django/issues/355 Handle the case where the user has not registered a `family-name` and ORCID returns `None`. --- CHANGELOG.md | 5 +++++ social_core/backends/orcid.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1783c865..6b570d97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [Unreleased] + +### Changed +- Handle case where user has not registered a `family-name` with ORCID + ## [4.5.4](https://github.com/python-social-auth/social-core/releases/tag/4.5.4) - 2024-04-25 ### Added diff --git a/social_core/backends/orcid.py b/social_core/backends/orcid.py index a2be9eaa..1f815f3b 100644 --- a/social_core/backends/orcid.py +++ b/social_core/backends/orcid.py @@ -76,7 +76,8 @@ def get_user_details(self, response): if name: first_name = name.get("given-names", {}).get("value", "") - last_name = name.get("family-name", {}).get("value", "") + if name.get("family-name", None) is not None: + last_name = name.get("family-name").get("value", "") emails = person.get("emails") if emails: