code: def linkCustomerToVerifiedUser(sender, **kwargs):
      
      registration = kwargs.get('registration', None)
  
      if not registration or (hasattr(registration.customer,'user') and registration.customer.user):
          return
  
      logger.debug('Checking for User for Customer with no associated registration.')
  
      customer = registration.customer
  
      try:
          verified_email = EmailAddress.objects.get(
              email=customer.email,
              verified=True,
              primary=True,
              user__customer__isnull=True
          )
  
          logger.info("Found user %s to associate with customer %s.", verified_email.user.id, customer.id)
  
          customer.user = verified_email.user
          customer.save()
  
          if not customer.user.first_name and not customer.user.last_name:
              customer.user.first_name = customer.first_name
              customer.user.last_name = customer.last_name
              customer.user.save()
      except ObjectDoesNotExist:
          logger.info("No user found to associate with customer %s.", customer.id)
      except MultipleObjectsReturned:
          # This should never happen, as email should be unique in the db table account_emailaddress.
          # If it does, something's broken in the database or Django.
          errmsg = "Something's not right with the database: more than one entry found on the database for the email %s. \
               This duplicate key value violates unique constraint \"account_emailaddress_email_key\". \
               The email field should be unique for each account.\n"
          logger.exception(errmsg, customer.email)
docs: If a Registration is processed in which the associated Customer does not yet
      have a User, then check to see if the Customer's email address has been
      verified as belonging to a specific User, and if that User has an associated
      Customer.  If such a User is found, then associated this Customer with that
      User.  This way, if a new User verifies their email account before they have
      submitted any Registrations, their Customer account is seamlessly linked when
      they do complete their first Registration.