Opened 8 years ago

Closed 7 years ago

#4819 closed (fixed)

django.contrib.auth.login doesn't just take any user, it needs one that's been modified by authenticate

Reported by: django@… Owned by: dakrauth
Component: Documentation Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Looking at http://www.djangoproject.com/documentation/authentication/, you'd think you could just pass in a request and a User. But you can't. The code for login needs the side effect caused by calling authenticate, which is to add the backend to the user object.

This is very frustrating when writing code where you'd like to log a user in automatically. At the very least, the documentation needs to be changed to reflect it.

Attachments (1)

auth_with_login.diff (1.1 KB) - added by dakrauth 7 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 8 years ago by Gary Wilson <gary.wilson@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Yes, this looks like it should be mentioned somewhere in the authentication docs and probably in login()'s docstring also.

comment:2 Changed 8 years ago by deepak <deep.thukral@…>

  • Component changed from Contrib apps to Documentation

comment:3 Changed 7 years ago by dakrauth

  • Owner changed from nobody to dakrauth
  • Status changed from new to assigned

Changed 7 years ago by dakrauth

comment:4 Changed 7 years ago by dakrauth

  • Has patch set

Mentioned the need for login() to take a pre-authenticated User object.

comment:5 Changed 7 years ago by dakrauth

  • Triage Stage changed from Accepted to Ready for checkin

Ready for review.

comment:6 Changed 7 years ago by ubernostrum

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [6805]) Fixed #4819: documented the need to call authenticate() before login(), based on a patch from Davd Krauth.

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