jumpserver/apps/orgs/middleware.py

17 lines
397 B
Python
Raw Normal View History

2018-07-12 16:00:35 +00:00
# -*- coding: utf-8 -*-
#
2018-07-13 07:05:46 +00:00
from .utils import get_org_from_request, set_current_org
2018-07-12 16:00:35 +00:00
class OrgMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
org = get_org_from_request(request)
request.current_org = org
2018-07-13 07:05:46 +00:00
set_current_org(org)
2018-07-12 16:00:35 +00:00
response = self.get_response(request)
return response