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

Commit

Permalink
Provide request to contrib.auth.authenticate in JSONWebTokenSerializer
Browse files Browse the repository at this point in the history
  • Loading branch information
gtnx committed Oct 9, 2017
1 parent 0a0bd40 commit edeedd7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rest_framework_jwt/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from calendar import timegm
from datetime import datetime, timedelta

import django
from django.contrib.auth import authenticate, get_user_model
from django.utils.translation import ugettext as _
from rest_framework import serializers
Expand Down Expand Up @@ -47,7 +48,10 @@ def validate(self, attrs):
}

if all(credentials.values()):
user = authenticate(**credentials)
if django.__version__ >= "1.11":
user = authenticate(request=self.context.get('request'), **credentials)
else:
user = authenticate(**credentials)

if user:
if not user.is_active:
Expand Down

0 comments on commit edeedd7

Please sign in to comment.