Django

Code

Ticket #2332 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

[patch] is_loggedin method for User and AnonymousUser models.

Reported by: SmileyChris Assigned to: adrian
Milestone: Component: Contrib apps
Version: Keywords: auth user
Cc: gary.wilson@gmail.com Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

This is_loggedin method replaces the is_anonymous method.

Discussion from the django-developers group follows (see thread).

Templates treat non-existing variables as False; therefore; a request.user somehow failing to get assigned would result in the template treating the user as they are authenticated (is_anonymous evaluates False). An is_loggedin would be a more secure option because if request.user failed to get assigned, the template would treat the user as anonymous.

I would much rather mistakenly treat an authenticated user as anonymous than mistakenly treat an anonymous user as authenticated.

Attachments

is_loggedin.patch (8.8 kB) - added by SmileyChris on 07/11/06 22:33:27.
is_loggedin implementation - also replaces all is_anonymous references with negative is_loggedin
is_logged_in.diff (13.3 kB) - added by Gary Wilson <gary.wilson@gmail.com> on 07/11/06 23:25:36.
is_logged_in implementation with doc changes and deprecation warnings in is_anonymous
is_authenticated.diff (13.5 kB) - added by Gary Wilson <gary.wilson@gmail.com> on 07/17/06 20:01:57.
is_authenticated implementation with doc changes and NO deprecation warnings in is_anonymous
is_authenticated.2.diff (13.5 kB) - added by Gary Wilson <gary.wilson@gmail.com> on 07/17/06 20:09:01.
is_authenticated implementation with doc changes and NO deprecation warnings in is_anonymous, slight change in documentation wording

Change History

07/11/06 22:33:27 changed by SmileyChris

  • attachment is_loggedin.patch added.

is_loggedin implementation - also replaces all is_anonymous references with negative is_loggedin

07/11/06 22:53:34 changed by mtredinnick

I don't like the name. Either is_authenticated or is_logged_in seem better.

Although using "login" as a single word verb is becoming common and even acceptable in some style guides (when I rule the universe, there are going to be changes made, let me tell you), I don't think we should encourage "loggedin" to be its past tense. :-) That can be fixed when we apply this.

There are some docs changes required as well that are not in this patch.

07/11/06 23:25:36 changed by Gary Wilson <gary.wilson@gmail.com>

  • attachment is_logged_in.diff added.

is_logged_in implementation with doc changes and deprecation warnings in is_anonymous

07/13/06 21:10:25 changed by Gary Wilson <gary.wilson@gmail.com>

  • cc set to gary.wilson@gmail.com.

07/17/06 20:01:57 changed by Gary Wilson <gary.wilson@gmail.com>

  • attachment is_authenticated.diff added.

is_authenticated implementation with doc changes and NO deprecation warnings in is_anonymous

07/17/06 20:09:01 changed by Gary Wilson <gary.wilson@gmail.com>

  • attachment is_authenticated.2.diff added.

is_authenticated implementation with doc changes and NO deprecation warnings in is_anonymous, slight change in documentation wording

07/17/06 20:09:48 changed by Gary Wilson <gary.wilson@gmail.com>

  • summary changed from is_loggedin method for User and AnonymousUser models. to [patch] is_loggedin method for User and AnonymousUser models..

07/18/06 21:09:27 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [3360]) Fixed #2332 -- Introduced is_authenticated() method on User and AnonymousUser? classes. Recommended its use over is_anonymous in the docs. Changed internal Django use to match this recommendation. Thanks to SmileyChris? and Gary Wilson for the patch.


Add/Change #2332 ([patch] is_loggedin method for User and AnonymousUser models.)




Change Properties
Action