kpsul/kfet/middleware.py

17 lines
411 B
Python
Raw Normal View History

2016-09-01 00:45:44 +02:00
# -*- 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