From dab53cfd03b8ceaca79c739a2f9cba729e11d020 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 18 Jun 2020 22:54:09 +0200 Subject: [PATCH] flows/executor: call plan.next before pop so we can save plan ReevaluateMarker: use PolicyEngine without cache --- passbook/flows/markers.py | 1 + passbook/flows/views.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/passbook/flows/markers.py b/passbook/flows/markers.py index f4fd97178..628f0cf28 100644 --- a/passbook/flows/markers.py +++ b/passbook/flows/markers.py @@ -36,6 +36,7 @@ class ReevaluateMarker(StageMarker): def process(self, plan: "FlowPlan", stage: Stage) -> Optional[Stage]: """Re-evaluate policies bound to stage, and if they fail, remove from plan""" engine = PolicyEngine(self.binding, self.user) + engine.use_cache = False engine.request.context = plan.context engine.build() result = engine.result diff --git a/passbook/flows/views.py b/passbook/flows/views.py index 65abf7ff3..affbe4536 100644 --- a/passbook/flows/views.py +++ b/passbook/flows/views.py @@ -138,6 +138,10 @@ class FlowExecutorView(View): stage_class=class_to_path(self.current_stage_view.__class__), flow_slug=self.flow.slug, ) + # We call plan.next here to check for re-evaluate markers + # this is important so we can save the result + # and we don't have to re-evaluate the policies each request + self.plan.next() self.plan.pop() self.request.session[SESSION_KEY_PLAN] = self.plan if self.plan.stages: