#2332 closed enhancement (fixed)
[patch] is_loggedin method for User and AnonymousUser models.
Reported by: | Chris Beaven | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Contrib apps | Version: | |
Severity: | normal | Keywords: | auth user |
Cc: | gary.wilson@… | Triage Stage: | Unreviewed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
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 (4)
Change History (8)
by , 18 years ago
Attachment: | is_loggedin.patch added |
---|
comment:1 by , 18 years ago
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.
by , 18 years ago
Attachment: | is_logged_in.diff added |
---|
is_logged_in implementation with doc changes and deprecation warnings in is_anonymous
comment:2 by , 18 years ago
Cc: | added |
---|
by , 18 years ago
Attachment: | is_authenticated.diff added |
---|
is_authenticated implementation with doc changes and NO deprecation warnings in is_anonymous
by , 18 years ago
Attachment: | is_authenticated.2.diff added |
---|
is_authenticated implementation with doc changes and NO deprecation warnings in is_anonymous, slight change in documentation wording
comment:3 by , 18 years ago
Summary: | is_loggedin method for User and AnonymousUser models. → [patch] is_loggedin method for User and AnonymousUser models. |
---|
comment:4 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
is_loggedin implementation - also replaces all is_anonymous references with negative is_loggedin