-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Correct return type in CustomTokenObtainPairSerializer.get_token…
… method
- Loading branch information
Showing
1 changed file
with
7 additions
and
5 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
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 | ||
|