diff --git a/passbook/core/templates/login/base.html b/passbook/core/templates/login/base.html index ae82cfe3c..15f99a209 100644 --- a/passbook/core/templates/login/base.html +++ b/passbook/core/templates/login/base.html @@ -63,11 +63,11 @@ {% endfor %} - {% if show_sign_up_notice %} + {% if enroll_url %}
{% endif %} diff --git a/passbook/flows/models.py b/passbook/flows/models.py index cb62df1f7..d24df11f5 100644 --- a/passbook/flows/models.py +++ b/passbook/flows/models.py @@ -56,6 +56,11 @@ class Flow(PolicyBindingModel, UUIDModel): PolicyBindingModel, parent_link=True, on_delete=models.CASCADE, related_name="+" ) + def related_flow(self, designation: str) -> 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.objects.filter(designation=designation).first() + def __str__(self) -> str: return f"Flow {self.name} ({self.slug})" diff --git a/passbook/lib/default.yml b/passbook/lib/default.yml index 591a17109..867b3798d 100644 --- a/passbook/lib/default.yml +++ b/passbook/lib/default.yml @@ -19,9 +19,6 @@ error_reporting: false domain: localhost passbook: - sign_up: - # Enables signup, created users are stored in internal Database and created in LDAP if ldap.create_users is true - enabled: true password_reset: # Enable password reset, passwords are reset in internal Database and in LDAP if ldap.reset_password is true enabled: true @@ -30,7 +27,3 @@ passbook: # Optionally add links to the footer on the login page # - name: test # href: https://test - # Specify which fields can be used to authenticate. Can be any combination of `username` and `email` - uid_fields: - - username - - email diff --git a/passbook/stages/identification/stage.py b/passbook/stages/identification/stage.py index 9e9fb4b0b..81ca912f5 100644 --- a/passbook/stages/identification/stage.py +++ b/passbook/stages/identification/stage.py @@ -4,14 +4,15 @@ from typing import List, Optional from django.contrib import messages from django.db.models import Q from django.http import HttpResponse +from django.shortcuts import reverse from django.utils.translation import gettext as _ from django.views.generic import FormView from structlog import get_logger from passbook.core.models import Source, User +from passbook.flows.models import FlowDesignation from passbook.flows.planner import PLAN_CONTEXT_PENDING_USER from passbook.flows.stage import AuthenticationStage -from passbook.lib.config import CONFIG from passbook.stages.identification.forms import IdentificationForm from passbook.stages.identification.models import IdentificationStage @@ -33,11 +34,16 @@ class IdentificationStageView(FormView, AuthenticationStage): return [current_stage.template] def get_context_data(self, **kwargs): - kwargs["config"] = CONFIG.y("passbook") - kwargs["title"] = _("Log in to your account") - kwargs["primary_action"] = _("Log in") - # TODO: show this based on the existence of an enrollment flow - kwargs["show_sign_up_notice"] = CONFIG.y("passbook.sign_up.enabled") + # Check for related enrollment flow, add URL to view + enrollment_flow = self.executor.flow.related_flow(FlowDesignation.ENROLLMENT) + if enrollment_flow: + url = reverse( + "passbook_flows:flow-executor", + kwargs={"flow_slug": enrollment_flow.slug}, + ) + kwargs["enroll_url"] = url + + # Check all enabled source, add them if they have a UI Login button. kwargs["sources"] = [] sources = ( Source.objects.filter(enabled=True).order_by("name").select_subclasses()