temp
This commit is contained in:
parent
865cd3fee3
commit
f09549b61e
@ -3,7 +3,6 @@ import path from 'path';
|
|||||||
export const env = dotenv.config({
|
export const env = dotenv.config({
|
||||||
path: [path.resolve(process.cwd(), '.env'), path.resolve(process.cwd(), '.env.wxopen')],
|
path: [path.resolve(process.cwd(), '.env'), path.resolve(process.cwd(), '.env.wxopen')],
|
||||||
});
|
});
|
||||||
console.log(env.parsed);
|
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
domain: env.parsed?.DOMAIN,
|
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 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 res = await fetch(refreshUrl);
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
console.log(data);
|
|
||||||
return 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) {
|
if (!user) {
|
||||||
user = await User.createUser(unionid, unionid.slice(0, 8));
|
user = await User.createUser(unionid, unionid.slice(0, 8));
|
||||||
user.data = {
|
user.data = {
|
||||||
@ -38,9 +48,10 @@ export class WxServices {
|
|||||||
wxOpenid: token.openid,
|
wxOpenid: token.openid,
|
||||||
wxUnionId: unionid,
|
wxUnionId: unionid,
|
||||||
};
|
};
|
||||||
|
await user.save({ fields: ['data'] });
|
||||||
this.isNew = true;
|
this.isNew = true;
|
||||||
}
|
}
|
||||||
console.log('mp-user login=============', token.openid, token.unionid);
|
|
||||||
const tokenInfo = await user.createToken(null, 'plugin', {
|
const tokenInfo = await user.createToken(null, 'plugin', {
|
||||||
wx: {
|
wx: {
|
||||||
openid: token.openid,
|
openid: token.openid,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user