Django

Code

Ticket #2826 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

contrib.comments.views.comments.post_comment should check .is_authenticated() before trying to do a login.

Reported by: anonymous Assigned to: adrian
Milestone: Component: Contrib apps
Version: SVN Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

In django.contrib.comments.views.comments.post_comment there should be a check for not manipulator.get_user().is_authenticated() before trying to do a login(). Otherwise the login fails with:

Traceback (most recent call last):
File "c:\django\django\core\handlers\base.py" in get_response
  74. response = callback(request, *callback_args, **callback_kwargs)
File "c:\django\django\contrib\comments\views\comments.py" in post_comment
  222. login(request, manipulator.get_user())
File "c:\django\django\contrib\auth\__init__.py" in login
  53. request.session[BACKEND_SESSION_KEY] = user.backend

  AttributeError at /comments/post/
  'User' object has no attribute 'backend'
# If user gave correct username/password and wasn't already logged in, log them in
# so they don't have to enter a username/password again.
    if manipulator.get_user() and not manipulator.get_user().is_authenticated() and new_data.has_key('password') and manipulator.get_user().check_password(new_data['password']):
        from django.contrib.auth import login
        login(request, manipulator.get_user())

Attachments

Change History

10/24/06 12:00:03 changed by adrian

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

(In [3929]) Fixed #2826 -- Added .is_authenticated() check before login() in comments views

12/21/06 16:39:54 changed by anonymous

geat code!


Add/Change #2826 (contrib.comments.views.comments.post_comment should check .is_authenticated() before trying to do a login.)




Change Properties
Action