diff --git a/es/aspects/token.js b/es/aspects/token.js index 5441b1f01..936005d63 100644 --- a/es/aspects/token.js +++ b/es/aspects/token.js @@ -531,6 +531,7 @@ export async function loginByMobile(params, context) { } async function setUserInfoFromWechat(user, userInfo, context) { const application = context.getApplication(); + const applicationId = context.getApplicationId(); const config = application?.system?.config || application?.system?.platform?.config; const { nickname, gender, avatar } = userInfo; const { nickname: originalNickname, gender: originalGender, extraFile$entity, } = user; @@ -564,6 +565,7 @@ async function setUserInfoFromWechat(user, userInfo, context) { type: 'image', filename: '', bucket: '', + applicationId: applicationId, }), }, ]; @@ -1328,7 +1330,6 @@ function checkTokenEnvConsistency(env1, env2) { return false; } } - return true; } export async function refreshToken(params, context) { const { env, tokenValue } = params; diff --git a/es/components/wechatUser/login/index.js b/es/components/wechatUser/login/index.js index 17fdbbe83..dd95f3a5d 100644 --- a/es/components/wechatUser/login/index.js +++ b/es/components/wechatUser/login/index.js @@ -17,8 +17,8 @@ export default OakComponent({ this.setState({ loading: true, }); - const { features, t } = this; - const token = features.token.getToken(true); + // const { features, t } = this; + const token = this.features.token.getToken(true); const url = window.location.href; const urlParse = new URL(url); //格式 xx?code=xx&state=/xx/xx?d=xx @@ -27,7 +27,7 @@ export default OakComponent({ const wechatLoginId = urlParse?.searchParams?.get('wechatLoginId'); if (!code) { this.setState({ - error: t('missingCodeParameter'), + error: this.t('missingCodeParameter'), loading: false, }); return; @@ -42,7 +42,7 @@ export default OakComponent({ else { try { // web微信扫码跟公众号授权 - await features.token.loginWechat(code, { + await this.features.token.loginWechat(code, { wechatLoginId, }); this.setState({ @@ -52,7 +52,7 @@ export default OakComponent({ } catch (err) { this.setState({ - error: t('weChatLoginFailed'), + error: this.t('weChatLoginFailed'), loading: false, }); throw err; diff --git a/lib/aspects/token.js b/lib/aspects/token.js index df7108560..df6c4e9c3 100644 --- a/lib/aspects/token.js +++ b/lib/aspects/token.js @@ -535,6 +535,7 @@ async function loginByMobile(params, context) { exports.loginByMobile = loginByMobile; async function setUserInfoFromWechat(user, userInfo, context) { const application = context.getApplication(); + const applicationId = context.getApplicationId(); const config = application?.system?.config || application?.system?.platform?.config; const { nickname, gender, avatar } = userInfo; const { nickname: originalNickname, gender: originalGender, extraFile$entity, } = user; @@ -568,6 +569,7 @@ async function setUserInfoFromWechat(user, userInfo, context) { type: 'image', filename: '', bucket: '', + applicationId: applicationId, }), }, ]; diff --git a/src/aspects/token.ts b/src/aspects/token.ts index e7689e098..e40119726 100644 --- a/src/aspects/token.ts +++ b/src/aspects/token.ts @@ -742,6 +742,7 @@ async function setUserInfoFromWechat< context: Cxt ) { const application = context.getApplication(); + const applicationId = context.getApplicationId(); const config = application?.system?.config || application?.system?.platform?.config; const { nickname, gender, avatar } = userInfo; @@ -782,6 +783,7 @@ async function setUserInfoFromWechat< type: 'image', filename: '', bucket: '', + applicationId: applicationId!, }), }, ]; @@ -1899,7 +1901,7 @@ export async function refreshToken< ) { const { env, tokenValue } = params; const fn = context.openRootMode(); - let [ token ] = await context.select('token', { + let [token] = await context.select('token', { data: Object.assign({ env: 1, ...tokenProjection, @@ -1936,7 +1938,7 @@ export async function refreshToken< filter: { id: token.id, } - }, { }); + }, {}); fn(); return newValue; } diff --git a/src/components/wechatUser/login/index.ts b/src/components/wechatUser/login/index.ts index 6891c46a0..12baa8901 100644 --- a/src/components/wechatUser/login/index.ts +++ b/src/components/wechatUser/login/index.ts @@ -18,8 +18,7 @@ export default OakComponent({ this.setState({ loading: true, }); - const { features, t } = this; - const token = features.token.getToken(true); + const token = this.features.token.getToken(true); const url = window.location.href; const urlParse = new URL(url); //格式 xx?code=xx&state=/xx/xx?d=xx @@ -28,7 +27,7 @@ export default OakComponent({ const wechatLoginId = urlParse?.searchParams?.get('wechatLoginId') as string; if (!code) { this.setState({ - error: t('missingCodeParameter'), + error: this.t('missingCodeParameter'), loading: false, }); return; @@ -45,7 +44,7 @@ export default OakComponent({ } else { try { // web微信扫码跟公众号授权 - await features.token.loginWechat(code, { + await this.features.token.loginWechat(code, { wechatLoginId, }); this.setState({ @@ -54,7 +53,7 @@ export default OakComponent({ this.go(state); } catch (err) { this.setState({ - error: t('weChatLoginFailed'), + error: this.t('weChatLoginFailed'), loading: false, }); throw err;