mirror of https://github.com/django/django.git
Fixed #4049 -- Improved error handling in auth() context processor. Based on a patch from gregorth.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6356 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
e988aa3989
commit
c694587ebb
|
@ -13,11 +13,19 @@ def auth(request):
|
|||
"""
|
||||
Returns context variables required by apps that use Django's authentication
|
||||
system.
|
||||
|
||||
If there is no 'user' attribute in the request, uses AnonymousUser (from
|
||||
django.contrib.auth).
|
||||
"""
|
||||
if hasattr(request, 'user'):
|
||||
user = request.user
|
||||
else:
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
user = AnonymousUser()
|
||||
return {
|
||||
'user': request.user,
|
||||
'messages': request.user.get_and_delete_messages(),
|
||||
'perms': PermWrapper(request.user),
|
||||
'user': user,
|
||||
'messages': user.get_and_delete_messages(),
|
||||
'perms': PermWrapper(user),
|
||||
}
|
||||
|
||||
def debug(request):
|
||||
|
|
Loading…
Reference in New Issue