diff --git a/request_a_govuk_domain/request/middleware.py b/request_a_govuk_domain/request/middleware.py index af3ec7df..ea87a625 100644 --- a/request_a_govuk_domain/request/middleware.py +++ b/request_a_govuk_domain/request/middleware.py @@ -22,28 +22,27 @@ def is_valid_start_path(self, path: str): return False def is_valid_progress(self, request): + if request.session.get("registration_data") is None: + return False + for key in request.session.get("registration_data"): + if key not in [ + "applicant_email", + "applicant_name", + "applicant_phone", + "domain_name", + "domain_purpose", + "registrant_contact_email", + "registrant_contact_phone", + "registrant_email_address", + "registrant_full_name", + "registrant_organisation_name", + "registrant_phone", + "registrant_role", + "registrant_type", + "registrar_organisation", + "written_permission", + ]: + # A key in the session data is unknown. So go back to the beginning + request.session["registration_data"] = {} + return False return True - # if request.session.get("registration_data") is None: - # return False - # for key in request.session.get("registration_data"): - # if key not in [ - # "applicant_email", - # "applicant_name", - # "applicant_phone", - # "domain_name", - # "domain_purpose", - # "registrant_contact_email", - # "registrant_contact_phone", - # "registrant_email_address", - # "registrant_full_name", - # "registrant_organisation_name", - # "registrant_phone", - # "registrant_role", - # "registrant_type", - # "registrar_organisation", - # "written_permission", - # ]: - # # A key in the session data is invalid. So go back to the beginning - # request.session["registration_data"] = {} - # return False - # return True