From 845061c74ae670de2e1bc42b9ca1d7e647647091 Mon Sep 17 00:00:00 2001 From: xingc Date: Mon, 21 Apr 2025 22:34:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(auth):=20=E5=8E=BB=E9=99=A4=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=85=A5=E5=8F=82=E7=9A=84=E5=8E=86=E5=8F=B2=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/routers/auth/routes.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/routers/auth/routes.py b/core/routers/auth/routes.py index 9686072..aafa112 100644 --- a/core/routers/auth/routes.py +++ b/core/routers/auth/routes.py @@ -76,15 +76,16 @@ async def wechat_login( # 验证用户的存在/是否位首次登录 user: User | None = await db_crud.get(filters={'wechat_openid': openid}) if user is None: - if not payload.encrypted_data or not payload.iv: - await redis_conn.set(keyname, ujson.encode(wechat_session), ex=60 * 5) - return {'status': 4001, 'message': '首次登录需要用户授权信息'} - - if all([ + checked = all([ payload.phone, payload.nickname, payload.avatar_url, - ]) is False: + ]) + if checked is False and wechat_session_str is None: + await redis_conn.set(keyname, ujson.encode(wechat_session), ex=60 * 5) + return {'status': 4001, 'message': '首次登录需要用户授权信息'} + + if checked is False: raise HTTPException(status.HTTP_400_BAD_REQUEST, detail='请重试登录操作') # 注册用户