Re-revert email_success check

This commit is contained in:
Erin Song 2024-10-09 15:56:20 -07:00
parent aec1a4f0d4
commit 76fc71382d
No known key found for this signature in database

View file

@ -881,12 +881,13 @@ class DomainAddUserView(DomainFormBaseView):
Throws EmailSendingError.""" Throws EmailSendingError."""
requested_email = form.cleaned_data["email"] requested_email = form.cleaned_data["email"]
requestor = self.request.user requestor = self.request.user
email_success = True email_success = False
# look up a user with that email # look up a user with that email
try: try:
requested_user = User.objects.get(email=requested_email) requested_user = User.objects.get(email=requested_email)
except User.DoesNotExist: except User.DoesNotExist:
# no matching user, go make an invitation # no matching user, go make an invitation
email_success = True
return self._make_invitation(requested_email, requestor) return self._make_invitation(requested_email, requestor)
else: else:
# if user already exists then just send an email # if user already exists then just send an email
@ -894,6 +895,7 @@ class DomainAddUserView(DomainFormBaseView):
self._send_domain_invitation_email( self._send_domain_invitation_email(
requested_email, requestor, requested_user=requested_user, add_success=False requested_email, requestor, requested_user=requested_user, add_success=False
) )
email_success = True
except EmailSendingError: except EmailSendingError:
logger.warn( logger.warn(
"Could not send email invitation (EmailSendingError)", "Could not send email invitation (EmailSendingError)",
@ -902,7 +904,6 @@ class DomainAddUserView(DomainFormBaseView):
) )
messages.warning(self.request, "Could not send email invitation.") messages.warning(self.request, "Could not send email invitation.")
except OutsideOrgMemberError: except OutsideOrgMemberError:
email_send = False
logger.warn( logger.warn(
"Could not send email. Can not invite member of a .gov organization to a different organization.", "Could not send email. Can not invite member of a .gov organization to a different organization.",
self.object, self.object,