Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#4888 closed (fixed)

Fix Documentation: User authentication in Django

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

Description

In http://www.djangoproject.com/documentation/authentication/#writing-an-authentication-backend we read:

An authentication backend is a class that implements two methods:
``get_user(id)`` and ``authenticate(**credentials)``.

The ``get_user`` method takes an ``id`` -- which could be a username, database
ID or whatever -- and returns a ``User`` object.

Meanwhile...

$ svn cat django/contrib/auth/backends.py | grep get_user
    def get_user(self, user_id):

Additionaly code below may suggest it is complete backend class while it doesn't have get_user() method.

    class MyBackend:
        def authenticate(self, username=None, password=None):
            # Check the username/password and return a User.

Attachments (1)

authentication.txt.diff (1.4 KB) - added by Piotr Lewandowski <django@…> 8 years ago.

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by Piotr Lewandowski <django@…>

comment:1 Changed 8 years ago by Piotr Lewandowski <django@…>

  • Cc django@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Documentation: User authentication in Django fix to Fix Documentation: User authentication in Django

comment:2 Changed 8 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:3 Changed 8 years ago by russellm

  • Resolution set to wontfix
  • Status changed from new to closed

I'm not sure I see the value in these changes -- the existing text is accurate (in that it describes the methods they way they are used on a class), and provides a sample wrapper class for explanatory purposes. The proposed patch removes the explanatory context, but add the 'self' method to the examples. I think the existing text is much clearer.

comment:4 Changed 8 years ago by Piotr Lewandowski <django@…>

I can't see the reason why the documentation should be buggy. It clearly states that get_user takes an id whereas it actually takes user_id.

Don't you think that's oversight? You just referred to the second part of this ticket.

comment:5 Changed 8 years ago by adrian

  • Resolution changed from wontfix to fixed

(In [6297]) Fixed #4888 -- Fixed small confusion in docs/authentication.txt. Thanks, Piotr Lewandowski

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