diff --git a/passbook/core/templates/login/base.html b/passbook/core/templates/login/base.html index 15f99a209..6d1070dae 100644 --- a/passbook/core/templates/login/base.html +++ b/passbook/core/templates/login/base.html @@ -63,12 +63,21 @@ {% endfor %} - {% if enroll_url %} + {% if enroll_url or recovery_url %} {% endif %} diff --git a/passbook/stages/identification/stage.py b/passbook/stages/identification/stage.py index 81ca912f5..5c1a05e0a 100644 --- a/passbook/stages/identification/stage.py +++ b/passbook/stages/identification/stage.py @@ -34,14 +34,19 @@ class IdentificationStageView(FormView, AuthenticationStage): return [current_stage.template] def get_context_data(self, **kwargs): - # Check for related enrollment flow, add URL to view + # Check for related enrollment and recovery flow, add URL to view enrollment_flow = self.executor.flow.related_flow(FlowDesignation.ENROLLMENT) if enrollment_flow: - url = reverse( + kwargs["enroll_url"] = reverse( "passbook_flows:flow-executor", kwargs={"flow_slug": enrollment_flow.slug}, ) - kwargs["enroll_url"] = url + recovery_flow = self.executor.flow.related_flow(FlowDesignation.RECOVERY) + if recovery_flow: + kwargs["recovery_url"] = reverse( + "passbook_flows:flow-executor", + kwargs={"flow_slug": recovery_flow.slug}, + ) # Check all enabled source, add them if they have a UI Login button. kwargs["sources"] = [] diff --git a/passbook/stages/identification/tests.py b/passbook/stages/identification/tests.py index 4b98a098a..f3389c1ec 100644 --- a/passbook/stages/identification/tests.py +++ b/passbook/stages/identification/tests.py @@ -82,7 +82,7 @@ class TestIdentificationStage(TestCase): """Test that enrollment flow is linked correctly""" flow = Flow.objects.create( name="enroll-test", - slug="unique-string", + slug="unique-enrollment-string", designation=FlowDesignation.ENROLLMENT, ) @@ -93,3 +93,19 @@ class TestIdentificationStage(TestCase): ) self.assertEqual(response.status_code, 200) self.assertIn(flow.slug, response.rendered_content) + + def test_recovery_flow(self): + """Test that recovery flow is linked correctly""" + flow = Flow.objects.create( + name="enroll-test", + slug="unique-recovery-string", + designation=FlowDesignation.RECOVERY, + ) + + response = self.client.get( + reverse( + "passbook_flows:flow-executor", kwargs={"flow_slug": self.flow.slug} + ), + ) + self.assertEqual(response.status_code, 200) + self.assertIn(flow.slug, response.rendered_content)