69f748acbd
The design of middlewares has changed in Django 1.11
16 lines
411 B
Python
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
|