Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#2826 closed defect (fixed)

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

Reported by: anonymous Owned by: Adrian Holovaty
Component: Contrib apps Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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\" in get_response
  74. response = callback(request, *callback_args, **callback_kwargs)
File "c:\django\django\contrib\comments\views\" in post_comment
  222. login(request, manipulator.get_user())
File "c:\django\django\contrib\auth\" 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())

Change History (2)

comment:1 Changed 12 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

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

comment:2 Changed 11 years ago by anonymous

geat code!

Note: See TracTickets for help on using tickets.
Back to Top