diff --git a/src/sentry/web/frontend/auth_login.py b/src/sentry/web/frontend/auth_login.py index bca2e311c8e453..faf5dfc9fbd551 100644 --- a/src/sentry/web/frontend/auth_login.py +++ b/src/sentry/web/frontend/auth_login.py @@ -504,10 +504,11 @@ def org_exists(self, request: Request) -> bool: """ Returns True if the organization passed in a request exists. """ - return bool( + return request.subdomain is not None and ( organization_service.check_organization_by_slug( slug=request.subdomain, only_visible=True ) + is not None ) def can_register(self, request: Request) -> bool: @@ -563,13 +564,7 @@ def handle_basic_auth(self, request: Request, **kwargs) -> HttpResponseBase: op = request.POST.get("op") organization = kwargs.pop("organization", None) - org_exists = bool( - organization_service.check_organization_by_slug( - slug=request.subdomain, only_visible=True - ) - ) - - if request.method == "GET" and request.subdomain and org_exists: + if request.method == "GET" and request.subdomain and self.org_exists(request): urls = [ reverse("sentry-auth-organization", args=[request.subdomain]), reverse("sentry-register"),