Created
May 6, 2015 17:19
-
-
Save samirbr/ccafa412103607d5c2ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TokenViewSet(viewsets.GenericViewSet): | |
def retrieve(self, request, pk=None): | |
if request.user.is_authenticated(): | |
token, created = Token.objects.get_or_create(user=request.user) | |
return Response({ 'token': token.key }) | |
else: | |
return Response({ | |
'status': 'Access Denied!', | |
'message': 'This account is not active!' | |
}, status=status.HTTP_401_UNAUTHORIZED) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment