Mercurial > public > sg101
diff gpp/core/middleware.py @ 215:8c1832b9d815
Implement #84; additional checks on spammers; implement stranger status.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 29 May 2010 04:51:28 +0000 |
parents | |
children | 423c39ee44e0 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/core/middleware.py Sat May 29 04:51:28 2010 +0000 @@ -0,0 +1,16 @@ +"""Common middleware for the entire project.""" +from django.contrib.auth import logout + +class InactiveUserMiddleware(object): + """ + This middleware ensures users with is_active set to False get their + session destroyed and are treated as logged out. + This middleware should come after the 'django.contrib.auth.middleware. + AuthenticationMiddleware' in settings.py. + Idea taken from: http://djangosnippets.org/snippets/1105/ + """ + + def process_request(self, request): + if request.user.is_authenticated() and not request.user.is_active: + logout(request) +