fix: keep web add redirects on admin host

This commit is contained in:
Nick Sweeting 2026-05-31 14:09:19 -07:00
parent a1e518e5ab
commit 81212cb79c
No known key found for this signature in database
2 changed files with 9 additions and 2 deletions

View File

@ -1412,8 +1412,15 @@ class WebAddView(AddView):
if snapshot:
return redirect(f"/{snapshot.url_path}")
request_host = (request.get_host() or "").lower()
if (
request.user.is_authenticated
and not _get_request_config(request).PUBLIC_ADD_VIEW
and host_matches(request_host, get_web_host())
):
return redirect(build_admin_url(request.get_full_path(), request=request))
if not self.test_func():
request_host = (request.get_host() or "").lower()
if host_matches(request_host, get_web_host()):
return redirect(build_admin_url(request.get_full_path(), request=request))
if host_matches(request_host, get_admin_host()):

View File

@ -138,7 +138,7 @@ def test_archiveresult_admin_links_plugin_and_process():
process_html = str(admin.process_link(result))
assert "/admin/environment/plugins/builtin.wget/" in plugin_html
assert f"/admin/machine/process/{process.id}/change" in process_html
assert f"/admin/machine/process/{process.id.hex}/change" in process_html
def test_deleting_binary_and_process_records_preserves_results():