Skip to content

Commit

Permalink
Middleware: add check if request has user attribute (e.g. WSGIRequest…
Browse files Browse the repository at this point in the history
… doesn’t)
  • Loading branch information
fiee committed Feb 26, 2014
1 parent 440f6a7 commit 95c449f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions async_messages/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 95c449f

Please sign in to comment.