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

Commit 620bc5e

Browse files
committed
Merge pull request #70 from cenkbircanoglu/master
User import problem for custom users issue fixed
2 parents a61568c + f0f9849 commit 620bc5e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

rest_framework_jwt/authentication.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import jwt
2-
32
from django.utils.encoding import smart_text
43
from django.utils.translation import ugettext as _
54
from rest_framework import exceptions
6-
from rest_framework_jwt.settings import api_settings
75
from rest_framework.authentication import (BaseAuthentication,
86
get_authorization_header)
97

10-
try:
11-
from django.contrib.auth import get_user_model
12-
except ImportError: # Django < 1.5
13-
from django.contrib.auth.models import User
14-
else:
15-
User = get_user_model()
8+
from rest_framework_jwt.settings import api_settings
169

1710

1811
jwt_decode_handler = api_settings.JWT_DECODE_HANDLER
@@ -67,6 +60,12 @@ def authenticate_credentials(self, payload):
6760
"""
6861
Returns an active user that matches the payload's user id and email.
6962
"""
63+
try:
64+
from django.contrib.auth import get_user_model
65+
except ImportError: # Django < 1.5
66+
from django.contrib.auth.models import User
67+
else:
68+
User = get_user_model()
7069
try:
7170
user_id = jwt_get_user_id_from_payload(payload)
7271

0 commit comments

Comments
 (0)