1 from django.contrib.auth.middleware import AuthenticationMiddleware
2 from django.contrib.auth import logout
3 from forum.models.user import AnonymousUser
4 from forum.views.auth import forward_suspended_user
7 class ExtendedUser(AuthenticationMiddleware):
8 def process_request(self, request):
9 super(ExtendedUser, self).process_request(request)
10 if request.user.is_authenticated():
12 request.user = request.user.user
14 if request.user.is_suspended():
17 return forward_suspended_user(request, user)
22 logging.error("Unable to convert auth_user %s to forum_user: \n%s" % (
23 request.user.id, traceback.format_exc()
26 request.user = AnonymousUser()