events: discard notification if user has empty email (cherry-pick #8938) (#8951)

events: discard notification if user has empty email (#8938)

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
Co-authored-by: Jens L <jens@goauthentik.io>
This commit is contained in:
gcp-cherry-pick-bot[bot]
2024-03-18 12:01:46 +01:00
committed by GitHub
parent 6503a7b048
commit 63591e1710

View File

@ -451,6 +451,13 @@ class NotificationTransport(SerializerModel):
def send_email(self, notification: "Notification") -> list[str]:
"""Send notification via global email configuration"""
if notification.user.email.strip() == "":
LOGGER.info(
"Discarding notification as user has no email address",
user=notification.user,
notification=notification,
)
return None
subject_prefix = "authentik Notification: "
context = {
"key_value": {