From aeb3526b2591b3e6a28784a004a0862be0a50281 Mon Sep 17 00:00:00 2001 From: Bailey Stoner Date: Sun, 1 Jul 2018 00:55:04 -0700 Subject: [PATCH] Update ` request.user ` after authenticating. If we don't do this, then `request.user` will be the wrong instance after authenticating - which can lead to some weird issues. Specifically, in projects that use `request.user` in response middleware. --- rest_framework_jwt/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rest_framework_jwt/views.py b/rest_framework_jwt/views.py index 30cd4646..7a090e2e 100644 --- a/rest_framework_jwt/views.py +++ b/rest_framework_jwt/views.py @@ -66,6 +66,7 @@ def post(self, request, *args, **kwargs): token, expires=expiration, httponly=True) + request.user = user return response return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)