#20313: AnonymousUser should follow custom User implementation
-------------------------------------+-------------------------------------
     Reporter:  thinkingpotato@…     |                    Owner:
         Type:  New feature          |  thinkingpotato
    Component:  contrib.auth         |                   Status:  assigned
     Severity:  Normal               |                  Version:
     Keywords:                       |               Resolution:
    Has patch:  0                    |             Triage Stage:
  Needs tests:  0                    |  Unreviewed
Easy pickings:  0                    |      Needs documentation:  0
                                     |  Patch needs improvement:  0
                                     |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by ptone):

 The obvious workaround in current code is to just check if user is
 authenticated first, as documented here:

 https://docs.djangoproject.com/en/dev/topics/auth/default/#authentication-
 in-web-requests

 If the custom user method you are calling returns a value that you are
 checking truthiness on, then you can `and` it with is_authenticated using
 python's logic shortcutting.

 Adding one line, and one level of indent seems reasonable amount of effort
 given the alternative of having to define an anonymous mirror class for
 your custom user.

 This has the advantage of keeping it even more explicit in you code when
 you are doing something with an authenticated user.

 Is there something more than code conciseness that would be enabled by
 setting up a custom anon user? Perhaps I'm missing some of the argument in
 favor of doing this.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20313#comment:4>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to