stages/identification: add recovery support
This commit is contained in:
		@ -63,12 +63,21 @@
 | 
				
			|||||||
                    </li>
 | 
					                    </li>
 | 
				
			||||||
                    {% endfor %}
 | 
					                    {% endfor %}
 | 
				
			||||||
                </ul>
 | 
					                </ul>
 | 
				
			||||||
                {% if enroll_url %}
 | 
					                {% if enroll_url or recovery_url %}
 | 
				
			||||||
                <div class="pf-c-login__main-footer-band">
 | 
					                <div class="pf-c-login__main-footer-band">
 | 
				
			||||||
 | 
					                    {% if enroll_url %}
 | 
				
			||||||
                    <p class="pf-c-login__main-footer-band-item">
 | 
					                    <p class="pf-c-login__main-footer-band-item">
 | 
				
			||||||
                        {% trans 'Need an account?' %}
 | 
					                        {% trans 'Need an account?' %}
 | 
				
			||||||
                        <a href="{{ enroll_url }}">{% trans 'Sign up.' %}</a>
 | 
					                        <a href="{{ enroll_url }}">{% trans 'Sign up.' %}</a>
 | 
				
			||||||
                    </p>
 | 
					                    </p>
 | 
				
			||||||
 | 
					                    {% endif %}
 | 
				
			||||||
 | 
					                    {% if recovery_url %}
 | 
				
			||||||
 | 
					                    <p class="pf-c-login__main-footer-band-item">
 | 
				
			||||||
 | 
					                        <a href="{{ recovery_url }}">
 | 
				
			||||||
 | 
					                            {% trans 'Forgot username or password?' %}
 | 
				
			||||||
 | 
					                        </a>
 | 
				
			||||||
 | 
					                    </p>
 | 
				
			||||||
 | 
					                    {% endif %}
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
                {% endif %}
 | 
					                {% endif %}
 | 
				
			||||||
            </footer>
 | 
					            </footer>
 | 
				
			||||||
 | 
				
			|||||||
@ -34,14 +34,19 @@ class IdentificationStageView(FormView, AuthenticationStage):
 | 
				
			|||||||
        return [current_stage.template]
 | 
					        return [current_stage.template]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_context_data(self, **kwargs):
 | 
					    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)
 | 
					        enrollment_flow = self.executor.flow.related_flow(FlowDesignation.ENROLLMENT)
 | 
				
			||||||
        if enrollment_flow:
 | 
					        if enrollment_flow:
 | 
				
			||||||
            url = reverse(
 | 
					            kwargs["enroll_url"] = reverse(
 | 
				
			||||||
                "passbook_flows:flow-executor",
 | 
					                "passbook_flows:flow-executor",
 | 
				
			||||||
                kwargs={"flow_slug": enrollment_flow.slug},
 | 
					                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.
 | 
					        # Check all enabled source, add them if they have a UI Login button.
 | 
				
			||||||
        kwargs["sources"] = []
 | 
					        kwargs["sources"] = []
 | 
				
			||||||
 | 
				
			|||||||
@ -82,7 +82,7 @@ class TestIdentificationStage(TestCase):
 | 
				
			|||||||
        """Test that enrollment flow is linked correctly"""
 | 
					        """Test that enrollment flow is linked correctly"""
 | 
				
			||||||
        flow = Flow.objects.create(
 | 
					        flow = Flow.objects.create(
 | 
				
			||||||
            name="enroll-test",
 | 
					            name="enroll-test",
 | 
				
			||||||
            slug="unique-string",
 | 
					            slug="unique-enrollment-string",
 | 
				
			||||||
            designation=FlowDesignation.ENROLLMENT,
 | 
					            designation=FlowDesignation.ENROLLMENT,
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -93,3 +93,19 @@ class TestIdentificationStage(TestCase):
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
        self.assertEqual(response.status_code, 200)
 | 
					        self.assertEqual(response.status_code, 200)
 | 
				
			||||||
        self.assertIn(flow.slug, response.rendered_content)
 | 
					        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