From df92f01719fae5d90991b3af3ba5eb823d9615a8 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 29 May 2021 18:30:55 +0200 Subject: [PATCH] flows: remove default-recovery Signed-off-by: Jens Langhammer --- authentik/core/api/users.py | 8 +++++--- authentik/flows/models.py | 5 ----- authentik/flows/urls.py | 5 ----- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/authentik/core/api/users.py b/authentik/core/api/users.py index f36ecc258..566a8d39a 100644 --- a/authentik/core/api/users.py +++ b/authentik/core/api/users.py @@ -32,7 +32,7 @@ from authentik.core.middleware import ( ) from authentik.core.models import Token, TokenIntents, User from authentik.events.models import EventAction -from authentik.flows.models import Flow, FlowDesignation +from authentik.tenants.models import Tenant class UserSerializer(ModelSerializer): @@ -179,8 +179,9 @@ class UserViewSet(ModelViewSet): # pylint: disable=invalid-name, unused-argument def recovery(self, request: Request, pk: int) -> Response: """Create a temporary link that a user can use to recover their accounts""" + tenant: Tenant = request._request.tenant # Check that there is a recovery flow, if not return an error - flow = Flow.with_policy(request, designation=FlowDesignation.RECOVERY) + flow = tenant.flow_recovery if not flow: raise Http404 user: User = self.get_object() @@ -191,7 +192,8 @@ class UserViewSet(ModelViewSet): ) querystring = urlencode({"token": token.key}) link = request.build_absolute_uri( - reverse_lazy("authentik_flows:default-recovery") + f"?{querystring}" + reverse_lazy("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) + + f"?{querystring}" ) return Response({"link": link}) diff --git a/authentik/flows/models.py b/authentik/flows/models.py index 75c0bc930..eb6934361 100644 --- a/authentik/flows/models.py +++ b/authentik/flows/models.py @@ -142,11 +142,6 @@ class Flow(SerializerModel, PolicyBindingModel): LOGGER.debug("with_policy: no flow found", filters=flow_filter) return None - def related_flow(self, designation: str, request: HttpRequest) -> Optional["Flow"]: - """Get a related flow with `designation`. Currently this only queries - Flows by `designation`, but will eventually use `self` for related lookups.""" - return Flow.with_policy(request, designation=designation) - def __str__(self) -> str: return f"Flow {self.name} ({self.slug})" diff --git a/authentik/flows/urls.py b/authentik/flows/urls.py index 241eb3c5f..3dad06e53 100644 --- a/authentik/flows/urls.py +++ b/authentik/flows/urls.py @@ -16,11 +16,6 @@ urlpatterns = [ ToDefaultFlow.as_view(designation=FlowDesignation.INVALIDATION), name="default-invalidation", ), - path( - "-/default/recovery/", - ToDefaultFlow.as_view(designation=FlowDesignation.RECOVERY), - name="default-recovery", - ), path( "-/default/unenrollment/", ToDefaultFlow.as_view(designation=FlowDesignation.UNRENOLLMENT),