Changes between Initial Version and Version 1 of Ticket #34032
- Timestamp:
- Sep 22, 2022, 9:57:40 PM (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #34032 – Description
initial v1 7 7 After 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`. 8 8 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.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. 10 10 11 Some ideas I had for changing this that might've saved time in the future:11 Some ideas: 12 12 * `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?) 13 13 * `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) 14 14 * 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. 16 16 17 17 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. 18 Happy for some thoughts/feedback/pushback. This was just a painpoint for me while developing. 19 20 Perhaps it needs to be highlighted in the documentation?