django-rest-framework icon indicating copy to clipboard operation
django-rest-framework copied to clipboard

Make `APIClient.force_authenticate()` work with `user=None`

Open willbeaufoy opened this issue 2 years ago • 3 comments

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.

willbeaufoy avatar Oct 17 '21 14:10 willbeaufoy

We should have an added test for the case that was broken before to ensure it doesn't crop up again in the future.

kevin-brown avatar Oct 18 '21 22:10 kevin-brown

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.

willbeaufoy avatar Oct 18 '21 23:10 willbeaufoy

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.

stale[bot] avatar Apr 18 '22 06:04 stale[bot]

Closing this PR as it's being ignored - however it works well and is ready to merge.

willbeaufoy avatar Sep 13 '22 15:09 willbeaufoy

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.

tomchristie avatar Sep 14 '22 12:09 tomchristie

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.

willbeaufoy avatar Sep 14 '22 14:09 willbeaufoy

Thanks @willbeaufoy 😀

tomchristie avatar Sep 15 '22 08:09 tomchristie