Mercurial > public > sg101
changeset 231:a2d388ed106e
Guard against the request object not having a user attribute in my Who's online middleware. This can happen if a redirect is issued before the authentication middleware gets to run.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 14 Jul 2010 02:35:39 +0000 |
parents | 5ee9422ce83c |
children | a46788862737 |
files | gpp/core/middleware.py |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/gpp/core/middleware.py Tue Jul 13 03:51:37 2010 +0000 +++ b/gpp/core/middleware.py Wed Jul 14 02:35:39 2010 +0000 @@ -38,7 +38,12 @@ """ Keep track of who is online. """ - if request.is_ajax(): + # Note that some requests may not have a user attribute + # as these may have been redirected in the middleware chain before + # the auth middleware got a chance to run. If this is the case, just + # bail out. We also ignore AJAX requests. + + if not hasattr(request, 'user') or request.is_ajax(): return response if request.user.is_authenticated():