]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/middleware/extended_user.py
Adds a new function in the profile menu for admins to suspend users, indefinetly...
[osqa.git] / forum / middleware / extended_user.py
index e54c9b4aa50eeea05d80f7aac4daa98966e21704..0e44f736e2671b7cccf563e30c8ed54c1ec41e46 100644 (file)
@@ -1,12 +1,20 @@
 from django.contrib.auth.middleware import AuthenticationMiddleware\r
+from django.contrib.auth import logout\r
 from forum.models.user import AnonymousUser\r
+from forum.views.auth import forward_suspended_user\r
 \r
-class ExtendedUser(AuthenticationMiddleware):    \r
+class ExtendedUser(AuthenticationMiddleware):\r
     def process_request(self, request):\r
         super(ExtendedUser, self).process_request(request)\r
         if request.user.is_authenticated():\r
             try:\r
                 request.user = request.user.user\r
+\r
+                if request.user.is_suspended():\r
+                    user = request.user\r
+                    logout(request)\r
+                    return forward_suspended_user(request, user)\r
+\r
                 return None\r
             except:\r
                 pass\r