Changes between Initial Version and Version 1 of Ticket #34032


Ignore:
Timestamp:
Sep 22, 2022, 9:57:40 PM (2 years ago)
Author:
Dre Westcook
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34032 – Description

    initial v1  
    77After two days of debugging and re-reading docs, I found that I missed out a fairly critical sentence: "Authentication backends implements two required methods". -- my authentication backend (of which I was replacing the default) - did not implement `get_user()` so we would use the default `BaseBackend.get_user()` which is to `return None`.
    88
    9 To me, it wasn't quite obvious why the authentication system needs to implement get_user ( as i'd want to just get the user by pk like any other) so this was a little bit of time wasting that I feel could be made a bit more obvious. but I'm happy for other considerations.
     9To me, it wasn't quite obvious why the authentication system needs to implement get_user ( as i'd want to just get the user by pk like any other) so this was a little bit of time wasting that I feel could be made a bit more obvious.
    1010
    11 Some ideas I had for changing this that might've saved time in the future:
     11Some ideas:
    1212* `BaseBackend` to implement a simple `get_user_model().objects.get( _meta.pk=pk)` - seeming this is the default for most cases (as far as I know?)
    1313* `BaseBackend` to raise `NotImplemented` to force implementors to define ''these two required methods'' as that is what is mentioned in the docs (https://docs.djangoproject.com/en/4.1/topics/auth/customizing/#:~:text=implements%20two%20required%20methods)
    1414    * anyone requiring the failthrough approach so that one can auth and get_user on different backends can just `pass` it
    15 * something else
     15* something else.
    1616
    1717
    18 Happy for some thoughts /feedback / pushback. I just know that this was a painpoint for me and it wasn't obvious where the `AnonymousUser` was coming from. Perhaps it's just a documentation change.
     18Happy for some thoughts/feedback/pushback. This was just a painpoint for me while developing.
     19
     20Perhaps it needs to be highlighted in the documentation?
Back to Top