stages/identification: add recovery support
This commit is contained in:
@ -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"] = []
|
||||
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user