lrf402788946 před 4 roky
rodič
revize
bebcca2ac1
1 změnil soubory, kde provedl 5 přidání a 3 odebrání
  1. 5 3
      app/controller/weixin.js

+ 5 - 3
app/controller/weixin.js

@@ -65,8 +65,11 @@ class WeixinController extends Controller {
     assert(code, 'code不能为空');
     assert(state, 'state不能为空');
     console.log('code-->' + code);
-
     const { weixin } = this.ctx.service;
+    const key = `visit:auth:state:${state}`;
+    const val = await this.app.redis.get(key);
+    console.log(key);
+    console.log(val);
     let openid;
     try {
       ({ openid } = await weixin.fetch(code));
@@ -77,8 +80,7 @@ class WeixinController extends Controller {
     console.log('function in');
     console.log('openid--->' + openid);
     if (openid) {
-      const key = `visit:auth:state:${state}`;
-      const val = await this.app.redis.get(key);
+      
       const { redirect_uri, type, uid, qrcode, msgid, objid } = JSON.parse(val);
       console.log('redirect_uri-->' + redirect_uri);
       const user = await this.ctx.service.user.findByOpenid(openid);