core: fix impersonation not working with inactive users
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
		@ -26,6 +26,8 @@ class ImpersonateMiddleware:
 | 
			
		||||
 | 
			
		||||
        if SESSION_IMPERSONATE_USER in request.session:
 | 
			
		||||
            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)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -17,6 +17,9 @@ class TestImpersonation(TestCase):
 | 
			
		||||
 | 
			
		||||
    def test_impersonate_simple(self):
 | 
			
		||||
        """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.get(
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user