libushang 5 månader sedan
förälder
incheckning
af104e3877
2 ändrade filer med 9 tillägg och 15 borttagningar
  1. 1 1
      common/YzyApi.py
  2. 8 14
      routers/prod_api/auth.py

+ 1 - 1
common/YzyApi.py

@@ -197,8 +197,8 @@ def format_redirect_url(redirect_url: str) -> str:
         "rnd": new_guid()
     }
     state_str = json.dumps(state_json)
-    # print(state_str)
     state = base64.b64encode(state_str.encode('utf-8')).decode('utf-8')
+    print('state_base64:', state)
         
     detail_url = "https://open.weixin.qq.com/connect/Oauth2/authorize?appid={}&redirect_uri={}&response_type=code&scope=snsapi_base&agentid={}&state={}#wechat_redirect".format(
         YZY_CORPID,

+ 8 - 14
routers/prod_api/auth.py

@@ -242,19 +242,14 @@ async def yzy(
     state_json = json.loads(state_str)
     print(code, state_json)
 
-    if len(code) < 30:
-        resp = YzyApi.get_user_info(code)
-        if resp['errcode'] != 0:
-            return {
-                "code": 500,
-                "msg": "Code异常"
-            }
-        
-        user_id = resp['UserId']
-    else:
-        from utils import ase_utils
-        user_id = ase_utils.aesDecrypt(md5("c9128dee-912c-11ef-bf07-00ff257b5fc6"), code)
-        # user_id = "eb4kehgy6wj4qn0jhx1dk6"
+    resp = YzyApi.get_user_info(code)
+    if resp['errcode'] != 0:
+        return {
+            "code": 500,
+            "msg": "Code异常"
+        }
+
+    user_id = resp['UserId']
 
     row = db.query(YzyOrgUserEntity).filter(YzyOrgUserEntity.userid == user_id).first()
     if row is None:
@@ -272,7 +267,6 @@ async def yzy(
         }
     
     user_id = str(row.user_id)
-
     access_token_expires = timedelta(seconds = 7200)
     access_token = security.create_access_token(
         data={"sub": user_id}, expires_delta = access_token_expires