Kaydet (Commit) e1c8bc8f authored tarafından Tim Graham's avatar Tim Graham

Fixed #21790 -- Removed reliance on an assert in auth.get_user().

Thanks matklad for the report.
üst 20f455b3
......@@ -138,15 +138,17 @@ def get_user(request):
If no user is retrieved an instance of `AnonymousUser` is returned.
"""
from .models import AnonymousUser
user = None
try:
user_id = request.session[SESSION_KEY]
backend_path = request.session[BACKEND_SESSION_KEY]
assert backend_path in settings.AUTHENTICATION_BACKENDS
except KeyError:
pass
else:
if backend_path in settings.AUTHENTICATION_BACKENDS:
backend = load_backend(backend_path)
user = backend.get_user(user_id) or AnonymousUser()
except (KeyError, AssertionError):
user = AnonymousUser()
return user
user = backend.get_user(user_id)
return user or AnonymousUser()
def get_permission_codename(action, opts):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment