add mobile & national code to jwt access
This commit is contained in:
@@ -53,5 +53,7 @@ class CustomizedTokenObtainPairSerializer(TokenObtainPairSerializer): # noqa
|
|||||||
|
|
||||||
# Add custom claims
|
# Add custom claims
|
||||||
token['name'] = user.username
|
token['name'] = user.username
|
||||||
|
token['mobile'] = user.mobile
|
||||||
|
token['national_code'] = user.national_code
|
||||||
|
|
||||||
return token
|
return token
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import os.path
|
|
||||||
import random
|
|
||||||
|
|
||||||
from rest_captcha.settings import api_settings as settings
|
from rest_captcha.settings import api_settings as settings
|
||||||
from django.conf import settings as django_setting
|
|
||||||
from PIL import ImageFont, ImageDraw, Image
|
from PIL import ImageFont, ImageDraw, Image
|
||||||
from .serializers import noise_default
|
from .serializers import noise_default
|
||||||
from django.core.cache import caches
|
from django.core.cache import caches
|
||||||
from rest_captcha import captcha
|
|
||||||
from io import BytesIO as StringIO
|
from io import BytesIO as StringIO
|
||||||
|
from rest_captcha import captcha
|
||||||
|
import os.path
|
||||||
|
import random
|
||||||
|
|
||||||
cache = caches[settings.CAPTCHA_CACHE]
|
cache = caches[settings.CAPTCHA_CACHE]
|
||||||
|
|
||||||
@@ -15,6 +13,9 @@ path = os.path.dirname(__file__) + '/' # noqa
|
|||||||
|
|
||||||
|
|
||||||
def random_char_challenge(length):
|
def random_char_challenge(length):
|
||||||
|
"""
|
||||||
|
generate random captcha code
|
||||||
|
"""
|
||||||
chars = '123456789'
|
chars = '123456789'
|
||||||
ret = ''
|
ret = ''
|
||||||
for i in range(length):
|
for i in range(length):
|
||||||
@@ -23,6 +24,9 @@ def random_char_challenge(length):
|
|||||||
|
|
||||||
|
|
||||||
def generate_image(word):
|
def generate_image(word):
|
||||||
|
"""
|
||||||
|
generate captcha image
|
||||||
|
"""
|
||||||
font = ImageFont.load_default()
|
font = ImageFont.load_default()
|
||||||
size = settings.CAPTCHA_IMAGE_SIZE
|
size = settings.CAPTCHA_IMAGE_SIZE
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user