Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Commit ef75421

Browse files
committed
Provide request to contrib.auth.authenticate in JSONWebTokenSerializer
1 parent 0a0bd40 commit ef75421

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: rest_framework_jwt/serializers.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from calendar import timegm
44
from datetime import datetime, timedelta
55

6+
import django
67
from django.contrib.auth import authenticate, get_user_model
78
from django.utils.translation import ugettext as _
89
from rest_framework import serializers
@@ -47,7 +48,10 @@ def validate(self, attrs):
4748
}
4849

4950
if all(credentials.values()):
50-
user = authenticate(**credentials)
51+
if django.__version__ >= "1.11":
52+
user = authenticate(request=self.context.get('request'), **credentials)
53+
else:
54+
user = authenticate(**credentials)
5155

5256
if user:
5357
if not user.is_active:

0 commit comments

Comments
 (0)