django-rest-framework
django-rest-framework copied to clipboard
Make `APIClient.force_authenticate()` work with `user=None`
Description
See the issue: #8211 for why this is needed.
Previously force_authenticate()
called logout()
if no user is provided. However as described in the issue, there is
a case where we want to authenticate with a token but not a user, so we don't want to logout in this case.
We should have an added test for the case that was broken before to ensure it doesn't crop up again in the future.
We should have an added test for the case that was broken before to ensure it doesn't crop up again in the future.
Done, added test which fails without my new code.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Closing this PR as it's being ignored - however it works well and is ready to merge.
Hi @willbeaufoy.
I do think we want this, yes. No reason we shouldn't get this in and merged for the next release.
Thanks for the prompt.
Hi @willbeaufoy.
I do think we want this, yes. No reason we shouldn't get this in and merged for the next release.
Thanks for the prompt.
Ah great. I noticed it failed linting so I've just fixed this and pushed the update.
Thanks @willbeaufoy 😀