Mercurial > public > sg101
annotate gpp/core/middleware.py @ 218:6dbb8faef085
Implement #86, add a front page expiration date to news stories.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 01 Jun 2010 05:16:40 +0000 |
parents | 8c1832b9d815 |
children | 423c39ee44e0 |
rev | line source |
---|---|
bgneal@215 | 1 """Common middleware for the entire project.""" |
bgneal@215 | 2 from django.contrib.auth import logout |
bgneal@215 | 3 |
bgneal@215 | 4 class InactiveUserMiddleware(object): |
bgneal@215 | 5 """ |
bgneal@215 | 6 This middleware ensures users with is_active set to False get their |
bgneal@215 | 7 session destroyed and are treated as logged out. |
bgneal@215 | 8 This middleware should come after the 'django.contrib.auth.middleware. |
bgneal@215 | 9 AuthenticationMiddleware' in settings.py. |
bgneal@215 | 10 Idea taken from: http://djangosnippets.org/snippets/1105/ |
bgneal@215 | 11 """ |
bgneal@215 | 12 |
bgneal@215 | 13 def process_request(self, request): |
bgneal@215 | 14 if request.user.is_authenticated() and not request.user.is_active: |
bgneal@215 | 15 logout(request) |
bgneal@215 | 16 |