diff --git a/src/djangooidc/views.py b/src/djangooidc/views.py index b887b7a14..12b82f242 100644 --- a/src/djangooidc/views.py +++ b/src/djangooidc/views.py @@ -99,8 +99,11 @@ def login_callback(request): return CLIENT.create_authn_request(request.session) user = authenticate(request=request, **userinfo) if user: - # Set the verification type - user.set_user_verification_type() + # Set the verification type if it doesn't already exist + if not user.verification_type: + user.set_user_verification_type() + user.save() + login(request, user) logger.info("Successfully logged in user %s" % user) diff --git a/src/registrar/models/user.py b/src/registrar/models/user.py index 9320a80ff..423f93595 100644 --- a/src/registrar/models/user.py +++ b/src/registrar/models/user.py @@ -168,20 +168,10 @@ class User(AbstractUser): return verification_type def set_user_verification_type(self): - if self.verification_type is None: - # Would need to check audit log - retrieved = DomainInvitation.DomainInvitationStatus.RETRIEVED - user_exists = self.existing_user(self.username) - verification_type = self.get_verification_type_from_email(self.email, invitation_status=retrieved) - - # This should check if the type is unknown, use check_if_user_exists? - if verification_type == self.VerificationTypeChoices.REGULAR and not user_exists: - raise ValueError(f"No verification_type was found for {self} with id: {self.pk}") - else: - self.verification_type = verification_type - return self.verification_type - else: - return self.verification_type + # Would need to check audit log + retrieved = DomainInvitation.DomainInvitationStatus.RETRIEVED + verification_type = self.get_verification_type_from_email(self.email, invitation_status=retrieved) + self.verification_type = verification_type def check_domain_invitations_on_login(self): """When a user first arrives on the site, we need to retrieve any domain