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