diff --git a/django/contrib/auth/decorators.py b/django/contrib/auth/decorators.py
index f3f7f53..d1d69cd 100644
a
|
b
|
|
1 | 1 | from django.contrib.auth import REDIRECT_FIELD_NAME |
2 | | from django.http import HttpResponseRedirect |
| 2 | from django.http import HttpResponseRedirect, HttpResponseForbidden |
3 | 3 | from django.utils.http import urlquote |
4 | 4 | |
5 | 5 | def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): |
… |
… |
class _CheckLogin(object):
|
60 | 60 | def __call__(self, request, *args, **kwargs): |
61 | 61 | if self.test_func(request.user): |
62 | 62 | return self.view_func(request, *args, **kwargs) |
63 | | path = urlquote(request.get_full_path()) |
64 | | tup = self.login_url, self.redirect_field_name, path |
65 | | return HttpResponseRedirect('%s?%s=%s' % tup) |
| 63 | elif not request.user.is_authenticated(): |
| 64 | path = urlquote(request.get_full_path()) |
| 65 | tup = self.login_url, self.redirect_field_name, path |
| 66 | return HttpResponseRedirect('%s?%s=%s' % tup) |
| 67 | else: |
| 68 | return HttpResponseForbidden('<h1>Permission denied</h1>') |
| 69 | |