mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2024-11-22 17:16:34 +03:00
make IS_TEST not required, enhancement in Login view
This commit is contained in:
parent
7825890462
commit
44e0f33b25
|
@ -27,13 +27,6 @@ urlpatterns = patterns('rest_auth.views',
|
|||
name='rest_password_change'),
|
||||
)
|
||||
|
||||
if settings.DEBUG and not settings.IS_TEST:
|
||||
urlpatterns += patterns('',
|
||||
# Swagger Docs
|
||||
url(r'^docs/',
|
||||
include('rest_framework_swagger.urls')),
|
||||
)
|
||||
|
||||
if settings.IS_TEST:
|
||||
if getattr(settings, 'IS_TEST', False):
|
||||
from django.contrib.auth.tests import urls
|
||||
urlpatterns += patterns('', url(r'^test-admin/', include(urls)))
|
||||
|
|
|
@ -68,6 +68,8 @@ class Login(LoggedOutRESTAPIView, GenericAPIView):
|
|||
"""
|
||||
|
||||
serializer_class = LoginSerializer
|
||||
token_model = Token
|
||||
token_serializer = TokenSerializer
|
||||
|
||||
def post(self, request):
|
||||
# Create a serializer with request.DATA
|
||||
|
@ -86,8 +88,8 @@ class Login(LoggedOutRESTAPIView, GenericAPIView):
|
|||
login(request, user)
|
||||
|
||||
# Return REST Token object with OK HTTP status
|
||||
token, created = Token.objects.get_or_create(user=user)
|
||||
return Response(TokenSerializer(token).data,
|
||||
token, created = self.token_model.objects.get_or_create(user=user)
|
||||
return Response(self.token_serializer(token).data,
|
||||
status=status.HTTP_200_OK)
|
||||
else:
|
||||
return Response({'error': 'This account is disabled.'},
|
||||
|
|
Loading…
Reference in New Issue
Block a user