-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2c00f3
commit d6fbe8b
Showing
4 changed files
with
31 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from rest_framework_simplejwt.serializers import TokenObtainPairSerializer | ||
|
||
|
||
class CustomTokenObtainPairSerializer(TokenObtainPairSerializer): | ||
def validate(self, attrs): | ||
data = super().validate(attrs) | ||
|
||
data['is_superuser'] = self.user.is_superuser | ||
|
||
return data |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from django.urls import path | ||
from rest_framework_simplejwt import views as jwt_views | ||
|
||
from lavocat.api.v1.core.views import TokenObtainPairView | ||
|
||
urlpatterns = [ | ||
path('api/token/', jwt_views.TokenObtainPairView.as_view(), name='jwt-auth'), | ||
path('api/token/', TokenObtainPairView.as_view(), name='jwt-auth'), | ||
] |
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,12 @@ | ||
from rest_framework_simplejwt.views import TokenViewBase | ||
|
||
from lavocat.api.v1.core.serializers import CustomTokenObtainPairSerializer | ||
|
||
|
||
class TokenObtainPairView(TokenViewBase): | ||
""" | ||
Takes a set of user credentials and returns an access and refresh JSON web | ||
token pair to prove the authentication of those credentials. | ||
""" | ||
|
||
serializer_class = CustomTokenObtainPairSerializer |