summaryrefslogtreecommitdiffstats
path: root/users/shortcuts.py
diff options
context:
space:
mode:
Diffstat (limited to 'users/shortcuts.py')
-rw-r--r--users/shortcuts.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/users/shortcuts.py b/users/shortcuts.py
index 65206a3..3e7618a 100644
--- a/users/shortcuts.py
+++ b/users/shortcuts.py
@@ -3,7 +3,7 @@ from django.http import Http404
from users.models import Domain, Identity
-def by_handle_or_404(request, handle, local=True, fetch=False):
+def by_handle_or_404(request, handle, local=True, fetch=False) -> Identity:
"""
Retrieves an Identity by its long or short handle.
Domain-sensitive, so it will understand short handles on alternate domains.
@@ -12,14 +12,17 @@ def by_handle_or_404(request, handle, local=True, fetch=False):
if "HTTP_HOST" not in request.META:
raise Http404("No hostname available")
username = handle
- domain_instance = Domain.get_local_domain(request.META["HTTP_HOST"])
+ domain_instance = Domain.get_domain(request.META["HTTP_HOST"])
if domain_instance is None:
raise Http404("No matching domains found")
domain = domain_instance.domain
else:
username, domain = handle.split("@", 1)
# Resolve the domain to the display domain
- domain = Domain.get_local_domain(request.META["HTTP_HOST"]).domain
+ domain_instance = Domain.get_domain(domain)
+ if domain_instance is None:
+ raise Http404("No matching domains found")
+ domain = domain_instance.domain
identity = Identity.by_username_and_domain(
username,
domain,