From afb84c7bc5dd095b406ff7fc8ab90adf79776db4 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 13 Jun 2021 14:14:41 +0200 Subject: [PATCH] flows: fix error clearing flow background when no files have been uploaded Signed-off-by: Jens Langhammer --- authentik/core/templates/if/end_session.html | 10 ---------- authentik/flows/api/flows.py | 8 ++++++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/authentik/core/templates/if/end_session.html b/authentik/core/templates/if/end_session.html index 5dbc26898..9d98f1af4 100644 --- a/authentik/core/templates/if/end_session.html +++ b/authentik/core/templates/if/end_session.html @@ -3,16 +3,6 @@ {% load static %} {% load i18n %} -{% block head %} -{{ block.super }} - -{% endblock %} - {% block title %} {% trans 'End session' %} - {{ tenant.branding_title }} {% endblock %} diff --git a/authentik/flows/api/flows.py b/authentik/flows/api/flows.py index 48b0fd23e..3ec01cc2f 100644 --- a/authentik/flows/api/flows.py +++ b/authentik/flows/api/flows.py @@ -303,8 +303,12 @@ class FlowViewSet(UsedByMixin, ModelViewSet): background = request.FILES.get("file", None) clear = request.data.get("clear", False) if clear: - # .delete() saves the model by default - flow.background.delete() + if flow.background_url.startswith("/media"): + # .delete() saves the model by default + flow.background.delete() + else: + flow.background = None + flow.save() return Response({}) if background: flow.background = background