X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/bc6579a5a090016d4f7ade2d2e47ebc2177b9c41..174c53e97bcf1e5412c141829d152aa5a2b8684c:/forum/middleware/extended_user.py diff --git a/forum/middleware/extended_user.py b/forum/middleware/extended_user.py index e54c9b4..0e44f73 100644 --- a/forum/middleware/extended_user.py +++ b/forum/middleware/extended_user.py @@ -1,12 +1,20 @@ from django.contrib.auth.middleware import AuthenticationMiddleware +from django.contrib.auth import logout from forum.models.user import AnonymousUser +from forum.views.auth import forward_suspended_user -class ExtendedUser(AuthenticationMiddleware): +class ExtendedUser(AuthenticationMiddleware): def process_request(self, request): super(ExtendedUser, self).process_request(request) if request.user.is_authenticated(): try: request.user = request.user.user + + if request.user.is_suspended(): + user = request.user + logout(request) + return forward_suspended_user(request, user) + return None except: pass