Permalink
Browse files

Merge pull request #8 from fiee/master

Middleware: add check if request has user attribute
  • Loading branch information...
2 parents 440f6a7 + 95c449f commit ca6d74de7be37363b122de848d07caf29bbeb963 @codeinthehole committed Mar 5, 2014
Showing with 5 additions and 3 deletions.
  1. +5 −3 async_messages/middleware.py
@@ -6,9 +6,11 @@
class AsyncMiddleware(object):
def process_response(self, request, response):
- # Check for messages for this user and, if it exists,
- # call the messages API with it
- if hasattr(request, "session") and request.user.is_authenticated():
+ """
+ Check for messages for this user and, if it exists,
+ call the messages API with it
+ """
+ if hasattr(request, "session") and hasattr(request, "user") and request.user.is_authenticated():
msgs = get_messages(request.user)
if msgs:
for msg, level in msgs:

0 comments on commit ca6d74d

Please sign in to comment.