2016-09-01 00:45:44 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from __future__ import (absolute_import, division,
|
|
|
|
print_function, unicode_literals)
|
|
|
|
from builtins import *
|
|
|
|
|
2016-09-02 01:24:14 +02:00
|
|
|
from django.http import HttpResponseForbidden
|
2016-08-19 06:20:37 +02:00
|
|
|
from kfet.backends import KFetBackend
|
|
|
|
|
|
|
|
class KFetAuthenticationMiddleware(object):
|
|
|
|
def process_request(self, request):
|
|
|
|
kfet_backend = KFetBackend()
|
|
|
|
temp_request_user = kfet_backend.authenticate(request)
|
|
|
|
if temp_request_user:
|
2016-08-20 23:31:30 +02:00
|
|
|
request.real_user = request.user
|
2016-08-19 06:20:37 +02:00
|
|
|
request.user = temp_request_user
|
2016-09-02 01:24:14 +02:00
|
|
|
if request.user.has_perm('kfet.is_team'):
|
|
|
|
try:
|
|
|
|
request.user.profile.account_kfet
|
|
|
|
except RelatedObjectDoesNotExist:
|
|
|
|
return HttpResponseForbidden
|