-
Notifications
You must be signed in to change notification settings - Fork 0
/
serializers.py
22 lines (17 loc) · 933 Bytes
/
serializers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from rest_framework_simplejwt.serializers import TokenRefreshSerializer as BaseTokenRefreshSerializer
from rest_framework_simplejwt.exceptions import InvalidToken,TokenError
from djoser.serializers import UserCreateSerializer as BaseUserCreateSerializer\
, UserSerializer as BaseUserSerializer
class UserCreateSerializer(BaseUserCreateSerializer):
class Meta(BaseUserCreateSerializer.Meta):
fields = ['id','username','password','first_name','last_name']
class UserSerializer(BaseUserSerializer):
class Meta(BaseUserSerializer.Meta):
fields = ['id','username','first_name','last_name']
class TokenRefreshSerializer(BaseTokenRefreshSerializer):
refresh = None
def validate(self, attrs):
attrs['refresh'] = self.context['request'].COOKIES.get('refresh_token')
if attrs['refresh']:
return super().validate(attrs)
raise InvalidToken