code: def setup_user_email(request, user, addresses):
      
      from .models import EmailAddress
  
      assert not EmailAddress.objects.filter(user=user).exists()
      priority_addresses = []
      # Is there a stashed e-mail?
      adapter = get_adapter(request)
      stashed_email = adapter.unstash_verified_email(request)
      if stashed_email:
          priority_addresses.append(EmailAddress(user=user,
                                                 email=stashed_email,
                                                 primary=True,
                                                 verified=True))
      email = user_email(user)
      if email:
          priority_addresses.append(EmailAddress(user=user,
                                                 email=email,
                                                 primary=True,
                                                 verified=False))
      addresses, primary = cleanup_email_addresses(
          request,
          priority_addresses + addresses)
      for a in addresses:
          a.user = user
          a.save()
      EmailAddress.objects.fill_cache_for_user(user, addresses)
      if (primary and email and email.lower() != primary.email.lower()):
          user_email(user, primary.email)
          user.save()
      return primary
docs: Creates proper EmailAddress for the user that was just signed
      up. Only sets up, doesn't do any other handling such as sending
      out email confirmation mails etc.