Opened 16 years ago

Closed 15 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: David A Krauth
Component: Documentation Version: dev
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Looking at, 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 David A Krauth 15 years ago.

Download all attachments as: .zip

Change History (7)

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

Triage Stage: UnreviewedAccepted

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

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

Component: Contrib appsDocumentation

comment:3 Changed 15 years ago by David A Krauth

Owner: changed from nobody to David A Krauth
Status: newassigned

Changed 15 years ago by David A Krauth

Attachment: auth_with_login.diff added

comment:4 Changed 15 years ago by David A Krauth

Has patch: set

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

comment:5 Changed 15 years ago by David A Krauth

Triage Stage: AcceptedReady for checkin

Ready for review.

comment:6 Changed 15 years ago by James Bennett

Resolution: fixed
Status: assignedclosed

(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