From b0b9bb4ce9f2b2f8a52d0fa173dafca17a44dd43 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz <henrik@levkowetz.com> Date: Wed, 17 Jun 2020 13:31:55 +0000 Subject: [PATCH] Added code in the OpenID registration scope to look for registration matches also by email, to handle the case where somebody registered with a new email and only added it to the datatracker later. In this case, we would not have connected up the registration and the person record when first notified. - Legacy-Id: 18008 --- ietf/ietfauth/tests.py | 2 +- ietf/ietfauth/utils.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ietf/ietfauth/tests.py b/ietf/ietfauth/tests.py index aedd946ef..f6e6319d3 100644 --- a/ietf/ietfauth/tests.py +++ b/ietf/ietfauth/tests.py @@ -728,7 +728,7 @@ class OpenIDConnectTests(TestCase): RoleFactory(name_id='chair', person=person) meeting = MeetingFactory(type_id='ietf', date=datetime.date.today()) MeetingRegistration.objects.create( - meeting=meeting, person=person, first_name=person.first_name(), last_name=person.last_name(), email=person.email()) + meeting=meeting, person=None, first_name=person.first_name(), last_name=person.last_name(), email=person.email()) # Get access authorisation session = {} diff --git a/ietf/ietfauth/utils.py b/ietf/ietfauth/utils.py index 0c7bc2fa7..9d658b7b3 100644 --- a/ietf/ietfauth/utils.py +++ b/ietf/ietfauth/utils.py @@ -24,6 +24,7 @@ import debug # pyflakes:ignore from ietf.group.models import Role, GroupFeatures from ietf.person.models import Person +from ietf.utils.log import log def user_is_person(user, person): """Test whether user is associated with person.""" @@ -249,10 +250,19 @@ class OidcExtraScopeClaims(oidc_provider.lib.claims.ScopeClaims): meeting = get_current_ietf_meeting() person = self.user.person reg = MeetingRegistration.objects.filter(person=person, meeting=meeting).first() - today = datetime.date.today() + debug.show('reg') + if not reg: + # No person match; try to match by email address. They could + # have registered with a new address and added it to the account + # later. + email_list = person.email_set.values_list('address') + reg = MeetingRegistration.objects.filter(email__in=email_list, meeting=meeting).first() + reg.person = person + reg.save() info = {} if reg: # maybe register attendence if logged in to follow a meeting + today = datetime.date.today() if meeting.date <= today <= meeting.end_date(): client = ClientRecord.objects.get(client_id=self.client.client_id) if client.name == 'Meetecho' and not reg.attended: