Skip to content

Commit

Permalink
fix: Correct return type in CustomTokenObtainPairSerializer.get_token…
Browse files Browse the repository at this point in the history
… method
  • Loading branch information
abbastoof committed Jul 8, 2024
1 parent 9850139 commit cb86fda
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Backend/auth_service/auth_service/user_auth/serializers.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
import asyncio
from rest_framework_simplejwt.tokens import Token


class CustomTokenObtainPairSerializer(TokenObtainPairSerializer):
@classmethod
def get_token(cls, user) -> dict:
def get_token(cls, user) -> Token:

"""
Get token method to generate tokens for the user.
This method overrides the get_token method of TokenObtainPairSerializer to generate tokens for the user.
This method overrides the get_token method of TokenObtainPairSerializer to generate tokens for the user.
It generates the tokens for the user and returns the tokens.
Args:
user: The user object.
Returns:
dict: The dictionary containing the tokens.
"""
token = super().get_token(user)
token["custom_claims"] = {"username": user.username, "password": user.password}
return token
return token

0 comments on commit cb86fda

Please sign in to comment.