Skip to content

Commit f4f4e80

Browse files
committed
fix: fail email sending if email address is empty
1 parent 9f22682 commit f4f4e80

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

internal/api/mail.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,18 @@ func (a *API) sendEmail(r *http.Request, tx *storage.Connection, u *models.User,
594594
externalURL := getExternalHost(ctx)
595595

596596
if emailActionType != mail.EmailChangeVerification {
597-
if u.GetEmail() != "" && !a.checkEmailAddressAuthorization(u.GetEmail()) {
597+
if u.GetEmail() == "" {
598+
return apierrors.NewInternalServerError("Unable to send email to a user with an empty email address")
599+
}
600+
601+
if !a.checkEmailAddressAuthorization(u.GetEmail()) {
598602
return apierrors.NewBadRequestError(apierrors.ErrorCodeEmailAddressNotAuthorized, "Email address %q cannot be used as it is not authorized", u.GetEmail())
599603
}
600604
} else {
605+
if u.EmailChange == "" {
606+
return apierrors.NewInternalServerError("Unable to change email address of user to an empty value")
607+
}
608+
601609
// first check that the user can update their address to the
602610
// new one in u.EmailChange
603611
if u.EmailChange != "" && !a.checkEmailAddressAuthorization(u.EmailChange) {

0 commit comments

Comments
 (0)