#24501: Documentation for user_passes_test is wrong and confusing
-------------------------------+--------------------
     Reporter:  lietu          |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  Documentation  |    Version:  1.7
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 On the page https://docs.djangoproject.com/en/1.7/topics/auth/default/ it
 says on "Limiting access to logged-in users that pass a test" (
 https://docs.djangoproject.com/en/1.7/topics/auth/default/#limiting-
 access-to-logged-in-users-that-pass-a-test ) the following:

   {{{
   The simple way is to run your test on request.user in the view directly.
 For example, this view checks to make sure the user has an email in the
 desired domain:

   def my_view(request):
       if not request.user.email.endswith('@example.com'):
           return HttpResponse("You can't vote in this poll.")
       # ...
   }}}

 Then under that there's the "user_passes_test" -documentation and it's
 mentioned to be a shortcut for the above.

 This is just plain wrong, user_passes_test checks for something, then
 redirects to login page if the test fails. It does not return
 HttpResponse("You can't vote in this poll.") and it definitely does not
 return the 403 that makes me expect it to return.

 Also there is only a very casual mention of the "login_url" argument but
 no mention of what it could possibly be used for, e.g. redirecting users
 there if the test fails.

--
Ticket URL: <https://code.djangoproject.com/ticket/24501>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/048.2b3f77fa075cac666bde9c4d2cc98a3a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to