-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement django-rest-knox token authentication
- Loading branch information
1 parent
67017d9
commit c31dcbc
Showing
7 changed files
with
67 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from django.contrib.auth import login | ||
|
||
from rest_framework import permissions | ||
from rest_framework.authtoken.serializers import AuthTokenSerializer | ||
from knox.views import LoginView as KnoxLoginView | ||
|
||
|
||
class LoginView(KnoxLoginView): | ||
permission_classes = (permissions.AllowAny,) | ||
|
||
def post(self, request, format=None): | ||
serializer = AuthTokenSerializer(data=request.data) | ||
serializer.is_valid(raise_exception=True) | ||
user = serializer.validated_data["user"] | ||
login(request, user) | ||
return super(LoginView, self).post(request, format=None) |
This file contains 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