File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -6,14 +6,16 @@ class OrganisationFromSubdomainMiddleware(MiddlewareMixin):
66 Middleware pour extraire le sous-domaine de la requête et attacher l'organisation à request.organisation
77 """
88 def process_request (self , request ):
9- host = request .get_host ().split (':' )[0 ] # retire le port éventuel
10- # On suppose que le domaine principal est map-action.com
11- # et que le sous-domaine correspond à l'organisation
12- parts = host .split ('.' )
13- if len (parts ) < 2 :
9+ subdomain = request .META .get ('HTTP_X_TENANT_SUBDOMAIN' )
10+ if not subdomain :
11+ host = request .get_host ().split (':' )[0 ]
12+ parts = host .split ('.' )
13+ subdomain = parts [0 ] if len (parts ) > 2 else None
14+
15+ if not subdomain :
1416 request .organisation = None
1517 return
16- subdomain = parts [ 0 ]
18+
1719 try :
1820 organisation = Organisation .objects .get (subdomain = subdomain )
1921 request .organisation = organisation
You can’t perform that action at this time.
0 commit comments