fix: When the organization does not exist, close ticket with an error.

This commit is contained in:
wangruidong 2025-02-13 17:49:46 +08:00 committed by w940853815
parent 5e9fabff1b
commit 7d0a901522

View File

@ -5,8 +5,8 @@ from contextlib import contextmanager
from functools import wraps from functools import wraps
from inspect import signature from inspect import signature
from werkzeug.local import LocalProxy
from django.conf import settings from django.conf import settings
from werkzeug.local import LocalProxy
from common.local import thread_local from common.local import thread_local
from .models import Organization from .models import Organization
@ -57,6 +57,8 @@ def get_org_from_request(request):
def set_current_org(org): def set_current_org(org):
if isinstance(org, (str, uuid.UUID)): if isinstance(org, (str, uuid.UUID)):
org = Organization.get_instance(org) org = Organization.get_instance(org)
if not org:
return
setattr(thread_local, 'current_org_id', org.id) setattr(thread_local, 'current_org_id', org.id)