temp
This commit is contained in:
		| @@ -3,7 +3,6 @@ import path from 'path'; | ||||
| export const env = dotenv.config({ | ||||
|   path: [path.resolve(process.cwd(), '.env'), path.resolve(process.cwd(), '.env.wxopen')], | ||||
| }); | ||||
| console.log(env.parsed); | ||||
|  | ||||
| export const config = { | ||||
|   domain: env.parsed?.DOMAIN, | ||||
|   | ||||
| @@ -109,7 +109,6 @@ export const refreshToken = async (refreshToken: string): Promise<RefreshToken> | ||||
|   const refreshUrl = `https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=${appId}&grant_type=refresh_token&refresh_token=${refreshToken}`; | ||||
|   const res = await fetch(refreshUrl); | ||||
|   const data = await res.json(); | ||||
|   console.log(data); | ||||
|   return data; | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -30,6 +30,16 @@ export class WxServices { | ||||
|         }, | ||||
|       }, | ||||
|     }); | ||||
|     // @ts-ignore | ||||
|     if (user && user.data.wxOpenid !== token.openid) { | ||||
|       user.data = { | ||||
|         ...user.data, | ||||
|         // @ts-ignore | ||||
|         wxOpenid: token.openid, | ||||
|       }; | ||||
|       await user.update({ data: user.data }); | ||||
|       console.log('mp-user login openid update=============', token.openid, token.unionid); | ||||
|     } | ||||
|     if (!user) { | ||||
|       user = await User.createUser(unionid, unionid.slice(0, 8)); | ||||
|       user.data = { | ||||
| @@ -38,9 +48,10 @@ export class WxServices { | ||||
|         wxOpenid: token.openid, | ||||
|         wxUnionId: unionid, | ||||
|       }; | ||||
|       await user.save({ fields: ['data'] }); | ||||
|       this.isNew = true; | ||||
|     } | ||||
|     console.log('mp-user login=============', token.openid, token.unionid); | ||||
|  | ||||
|     const tokenInfo = await user.createToken(null, 'plugin', { | ||||
|       wx: { | ||||
|         openid: token.openid, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user