sync from local backup
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import django
|
||||
import os
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chunyu_project.settings')
|
||||
django.setup()
|
||||
|
||||
from django.core.cache import caches
|
||||
from user.models import FUser
|
||||
from rest_framework_simplejwt.tokens import RefreshToken
|
||||
|
||||
cache = caches['default']
|
||||
email = 'test@testbug.com'
|
||||
|
||||
# Check if user exists
|
||||
user = FUser.objects.filter(email=email).first()
|
||||
if not user:
|
||||
user = FUser.objects.create_user(
|
||||
email=email,
|
||||
username=email,
|
||||
nickname='测试用户',
|
||||
is_active=True
|
||||
)
|
||||
print(f'Created user: {user.email}')
|
||||
|
||||
# Set verification code in cache
|
||||
key = f'register_{email}'
|
||||
cache.set(key, '88888888', timeout=600)
|
||||
val = cache.get(key)
|
||||
print(f'Verification code "{val}" set with key "{key}"')
|
||||
|
||||
# Generate token
|
||||
refresh = RefreshToken.for_user(user)
|
||||
print(f'ACCESS_TOKEN: {refresh.access_token}')
|
||||
print(f'REFRESH_TOKEN: {refresh}')
|
||||
Reference in New Issue
Block a user