core: fix impersonation not working with inactive users
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
715a71427e
commit
d789dcc28f
|
@ -26,6 +26,8 @@ class ImpersonateMiddleware:
|
||||||
|
|
||||||
if SESSION_IMPERSONATE_USER in request.session:
|
if SESSION_IMPERSONATE_USER in request.session:
|
||||||
request.user = request.session[SESSION_IMPERSONATE_USER]
|
request.user = request.session[SESSION_IMPERSONATE_USER]
|
||||||
|
# Ensure that the user is active, otherwise nothing will work
|
||||||
|
request.user.is_active = True
|
||||||
|
|
||||||
return self.get_response(request)
|
return self.get_response(request)
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@ class TestImpersonation(TestCase):
|
||||||
|
|
||||||
def test_impersonate_simple(self):
|
def test_impersonate_simple(self):
|
||||||
"""test simple impersonation and un-impersonation"""
|
"""test simple impersonation and un-impersonation"""
|
||||||
|
# test with an inactive user to ensure that still works
|
||||||
|
self.other_user.is_active = False
|
||||||
|
self.other_user.save()
|
||||||
self.client.force_login(self.akadmin)
|
self.client.force_login(self.akadmin)
|
||||||
|
|
||||||
self.client.get(
|
self.client.get(
|
||||||
|
|
Reference in a new issue