From 4a2cad580140f4d7bd9c40895a63fed1d4ea770f Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Wed, 23 Jan 2019 17:24:50 +0100 Subject: [PATCH] add a validation error for false template invitation email properties --- openslides/users/models.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/openslides/users/models.py b/openslides/users/models.py index 6cc715b8b..99d7faf23 100644 --- a/openslides/users/models.py +++ b/openslides/users/models.py @@ -232,10 +232,20 @@ class User(RESTModelMixin, PermissionsMixin, AbstractBaseUser): "password": self.default_password, } ) - message = message.format(**message_format) + try: + message = message.format(**message_format) + except KeyError as err: + raise ValidationError( + {"detail": f"Invalid property {err}."} + ) subject_format = format_dict({"event_name": config["general_event_name"]}) - subject = subject.format(**subject_format) + try: + subject = subject.format(**subject_format) + except KeyError as err: + raise ValidationError( + {"detail": f"Invalid property {err}."} + ) # Create an email and send it. email = mail.EmailMessage(