diff --git a/ietf/ietfauth/utils.py b/ietf/ietfauth/utils.py index 52f582ca86..3d494d5604 100644 --- a/ietf/ietfauth/utils.py +++ b/ietf/ietfauth/utils.py @@ -223,7 +223,7 @@ def is_bofreq_editor(user, doc): def openid_userinfo(claims, user): # Populate claims dict. person = get_object_or_404(Person, user=user) - email = person.email() + email = person.email_allowing_unactive() if person.photo: photo_url = person.cdn_photo_url() else: diff --git a/ietf/person/models.py b/ietf/person/models.py index a09656b810..f88a869755 100644 --- a/ietf/person/models.py +++ b/ietf/person/models.py @@ -145,6 +145,14 @@ def email(self): e = self.email_set.filter(active=True).order_by("-time").first() self._cached_email = e return self._cached_email + def email_allowing_unactive(self): + if not hasattr(self, "_cached_email_allowing_unactive"): + e = self.email() + if not e: + e = self.email_set.order_by("-time").first() + log.assertion(statement="e is not None", note=f"Person {self.pk} has no Email objects") + self._cached_email_allowing_unactive = e + return self._cached_email_allowin_unactive def email_address(self): e = self.email() if e: