stages/email: don't check that email templates exist on startup
#3692 this runs on both server and worker where only the worker needs to have the email templates Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
cd1a36fec4
commit
43a5aaa9df
|
@ -1,6 +1,4 @@
|
|||
"""authentik email stage config"""
|
||||
from django.template.exceptions import TemplateDoesNotExist
|
||||
from django.template.loader import get_template
|
||||
from structlog.stdlib import get_logger
|
||||
|
||||
from authentik.blueprints.apps import ManagedAppConfig
|
||||
|
@ -19,24 +17,3 @@ class AuthentikStageEmailConfig(ManagedAppConfig):
|
|||
def reconcile_load_stages_emails_tasks(self):
|
||||
"""Load stages.emails tasks"""
|
||||
self.import_module("authentik.stages.email.tasks")
|
||||
|
||||
def reconcile_stage_templates_valid(self):
|
||||
"""Ensure all stage's templates actually exist"""
|
||||
from authentik.events.models import Event, EventAction
|
||||
from authentik.stages.email.models import EmailStage, EmailTemplates
|
||||
|
||||
for stage in EmailStage.objects.all():
|
||||
try:
|
||||
get_template(stage.template)
|
||||
except TemplateDoesNotExist:
|
||||
LOGGER.warning("Stage template does not exist, resetting", path=stage.template)
|
||||
Event.new(
|
||||
EventAction.CONFIGURATION_ERROR,
|
||||
stage=stage,
|
||||
message=(
|
||||
f"Template {stage.template} does not exist, resetting to default."
|
||||
f" (Stage {stage.name})"
|
||||
),
|
||||
).save()
|
||||
stage.template = EmailTemplates.ACCOUNT_CONFIRM
|
||||
stage.save()
|
||||
|
|
Reference in a new issue