Commit 0dce5e03 by Brodie Rao

Replaced call to _CheckLogin.__call__ with a simpler reimplementation of the…

Replaced call to _CheckLogin.__call__ with a simpler reimplementation of the method, which fixes legitimate redirects being swallowed in controllers using the decorators.
parent efe8a06a
......@@ -9,14 +9,10 @@ __all__ = ['permission_required', 'user_passes_test']
class CheckLoginOrForbid(_CheckLogin):
def __call__(self, request, *args, **kwargs):
response = super(CheckLoginOrForbid, self).__call__(request, *args,
**kwargs)
if (isinstance(response, HttpResponseRedirect) and
request.user.is_authenticated()):
return HttpResponseForbidden('<h1>Permission denied</h1>')
if self.test_func(request.user):
return self.view_func(request, *args, **kwargs)
else:
return response
return HttpResponseForbidden('<h1>Permission denied</h1>')
def user_passes_test(test_func, login_url=None,
......
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