feat: 修改oid获取顺序,添加从cookie中获取

pull/4090/head
ibuler 2020-06-09 16:43:07 +08:00
parent 82f70cb0dc
commit 4d4a107101
1 changed files with 10 additions and 4 deletions

View File

@ -11,12 +11,18 @@ from .models import Organization
def get_org_from_request(request):
oid = request.META.get("HTTP_X_JMS_ORG")
# query中优先级最高
oid = request.GET.get("oid")
# 其次header
if not oid:
oid = request.META.get("HTTP_X_JMS_ORG")
# 其次cookie
if not oid:
oid = request.COOKIES.get('X-JMS-ORG')
# 其次session
if not oid:
oid = request.session.get("oid")
request_params_oid = request.GET.get("oid")
if request_params_oid:
oid = request.GET.get("oid")
if not oid:
oid = Organization.DEFAULT_ID