create initial models and mobile test for mojtaba eshaghi
This commit is contained in:
@@ -2,6 +2,7 @@ from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
|
||||
from apps.captcha_app import exceptions as captcha_exception
|
||||
from rest_framework_simplejwt.settings import api_settings
|
||||
from django.contrib.auth.models import update_last_login
|
||||
from apps.authentication.models import User
|
||||
from rest_framework import exceptions
|
||||
from django.core.cache import cache
|
||||
from typing import Any
|
||||
@@ -51,9 +52,12 @@ class CustomizedTokenObtainPairSerializer(TokenObtainPairSerializer): # noqa
|
||||
|
||||
token = super().get_token(user)
|
||||
|
||||
# get customized user
|
||||
auth_user_model = User.objects.get(username=user.username)
|
||||
|
||||
# Add custom claims
|
||||
token['name'] = user.username
|
||||
token['mobile'] = user.mobile
|
||||
token['national_code'] = user.national_code
|
||||
token['mobile'] = auth_user_model.mobile
|
||||
token['national_code'] = auth_user_model.national_code
|
||||
|
||||
return token
|
||||
|
||||
Reference in New Issue
Block a user