gestioCOF/kfet/middleware.py
Martin Pépin 69f748acbd Django1.11-style MiddleWares
The design of middlewares has changed in Django 1.11
2017-02-23 02:00:34 +01:00

16 lines
411 B
Python

# -*- coding: utf-8 -*-
from kfet.backends import KFetBackend
def kfet_auth_middleware(get_response):
kfet_backend = KFetBackend()
def middleware(request):
temp_request_user = kfet_backend.authenticate(request)
if temp_request_user:
request.real_user = request.user
request.user = temp_request_user
return get_response(request)
return middleware