form not logged in

This commit is contained in:
zandercymatics 2024-11-06 08:54:24 -07:00
parent 6532db84c6
commit fbf6430b5f
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
4 changed files with 6 additions and 29 deletions

View file

@ -7,6 +7,7 @@
"http://localhost:8080/", "http://localhost:8080/",
"http://localhost:8080/health/", "http://localhost:8080/health/",
"http://localhost:8080/request/", "http://localhost:8080/request/",
"http://localhost:8080/request/start",
"http://localhost:8080/request/organization/", "http://localhost:8080/request/organization/",
"http://localhost:8080/request/org_federal/", "http://localhost:8080/request/org_federal/",
"http://localhost:8080/request/org_election/", "http://localhost:8080/request/org_election/",

View file

@ -2820,28 +2820,3 @@ document.addEventListener('DOMContentLoaded', function() {
// Add event listener to the suborg dropdown to show/hide the suborg details section // Add event listener to the suborg dropdown to show/hide the suborg details section
select.addEventListener("change", () => toggleSuborganization()); select.addEventListener("change", () => toggleSuborganization());
})(); })();
(function handleDomainRequestIntro() {
const domainRequestId = document.getElementById("wizard-domain-request-id")?.value;
// Handle back button navigation and initial page load
function handleStartPage(event) {
if (window.location.pathname === "/request/start/") {
if (event && !event.persisted) return;
const domainRequestId = sessionStorage.getItem("domainRequestId");
console.log("Domain request ID retrieved:", domainRequestId);
}
}
if (domainRequestId) {
sessionStorage.setItem("domainRequestId", domainRequestId);
console.log("Domain request ID stored:", domainRequestId);
}
// Listen for back/forward navigation
window.addEventListener('pageshow', handleStartPage);
// Handle initial page load
handleStartPage();
})();

View file

@ -92,7 +92,7 @@ class CheckUserProfileMiddleware:
We set the "redirect" query param equal to where the user wants to go. We set the "redirect" query param equal to where the user wants to go.
If the user wants to go to '/request/', then we set that If the user wants to go to '/request/start/' or '/request/', then we set that
information in the query param. information in the query param.
Otherwise, we assume they want to go to the home page. Otherwise, we assume they want to go to the home page.
@ -100,7 +100,8 @@ class CheckUserProfileMiddleware:
# In some cases, we don't want to redirect to home. This handles that. # In some cases, we don't want to redirect to home. This handles that.
# Can easily be generalized if need be, but for now lets keep this easy to read. # Can easily be generalized if need be, but for now lets keep this easy to read.
custom_redirect = "domain-request:start" if request.path == "/request/" else None start_paths = ["/request/", "/request/start/"]
custom_redirect = "domain-request:start" if request.path in start_paths else None
# Don't redirect on excluded pages (such as the setup page itself) # Don't redirect on excluded pages (such as the setup page itself)
if not any(request.path.startswith(page) for page in self._get_excluded_pages(profile_page)): if not any(request.path.startswith(page) for page in self._get_excluded_pages(profile_page)):

View file

@ -49,9 +49,9 @@ class TestViews(TestCase):
@less_console_noise_decorator @less_console_noise_decorator
def test_domain_request_form_not_logged_in(self): def test_domain_request_form_not_logged_in(self):
"""Domain request form not accessible without a logged-in user.""" """Domain request form not accessible without a logged-in user."""
response = self.client.get("/request/") response = self.client.get(reverse("domain-request:start"))
self.assertEqual(response.status_code, 302) self.assertEqual(response.status_code, 302)
self.assertIn("/login?next=/request/", response.headers["Location"]) self.assertIn("/login?next=/request/start/", response.headers["Location"])
class TestWithUser(MockEppLib): class TestWithUser(MockEppLib):