调整接口,保证客户端登陆后下次自动登录

This commit is contained in:
kingmo888 2023-12-15 08:49:23 +08:00
parent 66a65b7923
commit 6b2c58c919
2 changed files with 10 additions and 6 deletions

View File

@ -91,18 +91,22 @@ def currentUser(request):
if request.method == 'GET':
result['error'] = '错误的提交方式!'
return JsonResponse(result)
postdata = json.loads(request.body)
rid = postdata.get('id', '')
uuid = postdata.get('uuid', '')
user = UserProfile.objects.filter(Q(rid=rid) & Q(uuid=uuid)).first()
token = RustDeskToken.objects.filter(Q(uid=user.id) & Q(rid=user.rid)).first()
access_token = request.META.get('HTTP_AUTHORIZATION', '')
access_token = access_token.split('Bearer ')[-1]
token = RustDeskToken.objects.filter(Q(access_token=access_token) ).first()
user = None
if token:
user = UserProfile.objects.filter(Q(id=token.uid)).first()
if user:
if token:
result['access_token'] = token.access_token
result['type'] = 'access_token'
result['user'] = {'name':user.username}
result['name'] = {user.username}
return JsonResponse(result)

View File

@ -23,7 +23,7 @@ CSRF_TRUSTED_ORIGINS = [os.environ.get("CSRF_TRUSTED_ORIGINS", "http://www.baidu
SECRET_KEY = 'j%7yjvygpih=6b%qf!q%&ixpn+27dngzdu-i3xh-^3xgy3^nnc'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
ALLOWED_HOSTS = ["*"]
AUTH_USER_MODEL = 'api.UserProfile' #AppName.自定义user