From 2009bcecb0c5ca7072733424c38acdedcab78ae9 Mon Sep 17 00:00:00 2001 From: DealiAxy Date: Fri, 9 Aug 2024 15:40:34 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=87=E4=BF=AE=E5=A4=8D=E4=BC=81?= =?UTF-8?q?=E4=B8=9A=E5=BE=AE=E4=BF=A1=E7=99=BB=E5=BD=95=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apps/account/apis/oauth2/wecom.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/apps/account/apis/oauth2/wecom.py b/src/apps/account/apis/oauth2/wecom.py index 236bf4f..2be3e87 100644 --- a/src/apps/account/apis/oauth2/wecom.py +++ b/src/apps/account/apis/oauth2/wecom.py @@ -1,5 +1,6 @@ +import traceback from django.conf import settings -from django.contrib.auth import login +from django.contrib.auth import login as django_login from django.contrib.auth.models import User from ninja import Router, Schema from ninja.errors import HttpError @@ -34,6 +35,7 @@ def login(request, payload: WecomLoginSchema): try: user_info = client.oauth.get_user_info(payload.code) except Exception as e: + traceback.print_exc() raise HttpError(400, f'请求企微登录接口出错:{e}') # user_id 实际上是手机号 @@ -51,8 +53,8 @@ def login(request, payload: WecomLoginSchema): UserClaim.objects.create(user=user, name='oauth2:wecom:userid', value=user_id) # 记录Django登录状态 - login(request, user) + django_login(request, user) token = generate_token({'username': user.username}) - return responses.ok('登录成功', token) + return responses.ok('登录成功', token.dict())