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='请重试登录操作') # 注册用户