diff --git a/uni_modules/uni-id-pages/changelog.md b/uni_modules/uni-id-pages/changelog.md index 5d47e6538ec2fc9fa3d1a80dbbff1a4ec66e43fa..110526348b916a42d49ab4b2a4c42a1a1909f773 100644 --- a/uni_modules/uni-id-pages/changelog.md +++ b/uni_modules/uni-id-pages/changelog.md @@ -1,5 +1,9 @@ +## 1.0.29(2022-11-10) +- uni-id-co 支持URL化方式请求 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#adapter-http) ## 1.0.28(2022-11-09) - uni-id-co 升级密码加密算法,支持hmac-sha256加密 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#password-safe) +- uni-id-co 新增 开发者可以自定义密码加密规则 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#custom-password-encrypt) +- uni-id-co 新增 支持将其他系统用户迁移至uni-id [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#move-users-to-uni-id) ## 1.0.27(2022-10-26) - uni-id-co 新增 secureNetworkHandshakeByWeixin 接口,用于建立和微信小程序的安全网络连接 ## 1.0.26(2022-10-18) diff --git a/uni_modules/uni-id-pages/package.json b/uni_modules/uni-id-pages/package.json index f8e5f2f7c46c00aa4a9de4ae4e23b277e634799b..714fa8c2001decdcbaad6a27396c6b681e9b80f2 100644 --- a/uni_modules/uni-id-pages/package.json +++ b/uni_modules/uni-id-pages/package.json @@ -1,7 +1,7 @@ { "id": "uni-id-pages", "displayName": "uni-id-pages", - "version": "1.0.28", + "version": "1.0.29", "description": "云端一体简单、统一、可扩展的用户中心页面模版", "keywords": [ "用户管理", diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js index e49306ed34dc90463f0276b67f6381981bada428..6d7279016eeb6bc0d0b96636cdfff1426f40d062 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js @@ -35,7 +35,8 @@ const ERROR = { UNBIND_NOT_SUPPORTED: 'uni-id-unbind-not-supported', UNBIND_UNIQUE_LOGIN: 'uni-id-unbind-unique-login', UNBIND_PASSWORD_NOT_EXISTS: 'uni-id-unbind-password-not-exists', - UNBIND_MOBILE_NOT_EXISTS: 'uni-id-unbind-mobile-not-exists' + UNBIND_MOBILE_NOT_EXISTS: 'uni-id-unbind-mobile-not-exists', + UNSUPPORTED_REQUEST: 'uni-id-unsupported-request' } function isUniIdError (errCode) { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/universal.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/universal.js new file mode 100644 index 0000000000000000000000000000000000000000..4bf46a0b31d1588b62de43104d03cf63d5fdfffe --- /dev/null +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/universal.js @@ -0,0 +1,47 @@ +const { ERROR } = require('./error') + +function getHttpClientInfo () { + const requestId = this.getUniCloudRequestId() + const { clientIP, userAgent, source, secretType = 'none' } = this.getClientInfo() + const { clientInfo = {} } = JSON.parse(this.getHttpInfo().body) + + return { + ...clientInfo, + clientIP, + userAgent, + source, + secretType, + requestId + } +} + +function getHttpUniIdToken () { + const { uniIdToken = '' } = JSON.parse(this.getHttpInfo().body) + + return uniIdToken +} + +function verifyHttpMethod () { + const { headers, httpMethod } = this.getHttpInfo() + + if (!/^application\/json/.test(headers['content-type']) || httpMethod.toUpperCase() !== 'POST') { + throw { + errCode: ERROR.UNSUPPORTED_REQUEST, + errMsg: 'unsupported request' + } + } +} + +function universal () { + if (this.getClientInfo().source === 'http') { + verifyHttpMethod.call(this) + this.getParams()[0] = JSON.parse(this.getHttpInfo().body).params + this.getUniversalClientInfo = getHttpClientInfo.bind(this) + this.getUniversalUniIdToken = getHttpUniIdToken.bind(this) + } else { + this.getUniversalClientInfo = this.getClientInfo + this.getUniversalUniIdToken = this.getUniIdToken + } +} + +module.exports = universal diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js index 840fea8a5399342ccd7d5f36020ad6c8770c98b5..d0e5d557a2fb78ab03eb8deec75470d8df1c5ede 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js @@ -12,6 +12,7 @@ const { isUniIdError } = require('./common/error') const middleware = require('./middleware/index') +const universal = require('./common/universal') const { registerAdmin, @@ -81,7 +82,10 @@ const { module.exports = { async _before () { - const clientInfo = this.getClientInfo() + // 支持 callFunction 与 URL化 + universal.call(this) + + const clientInfo = this.getUniversalClientInfo() /** * 检查clientInfo,无appId和uniPlatform时本云对象无法正常运行 * 此外需要保证用到的clientInfo字段均经过类型检查 @@ -581,5 +585,5 @@ module.exports = { /** * 安全网络握手,目前仅处理微信小程序安全网络握手 */ - secureNetworkHandshakeByWeixin + secureNetworkHandshakeByWeixin } diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js index 01109e01af2789024af09c50999da641c47dfbd9..f3024072b201ce05123140a1ec02b91220d1ea9e 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js @@ -40,7 +40,8 @@ const sentence = { 'uni-id-unbind-failed': 'Please bind first and then unbind', 'uni-id-unbind-not-supported': 'Unbinding is not supported', 'uni-id-unbind-mobile-not-exists': 'This is the only way to login at the moment, please bind your phone number and then try to unbind', - 'uni-id-unbind-password-not-exists': 'Please set a password first' + 'uni-id-unbind-password-not-exists': 'Please set a password first', + 'uni-id-unsupported-request': 'Unsupported request' } module.exports = { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js index f346e49fb8c2cde8a0da8ebb68e307fe6e6dcffc..7dfb041b1ea51a5c01562ec31a2a539e75a22812 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js @@ -40,7 +40,8 @@ const sentence = { 'uni-id-unbind-failed': '请先绑定后再解绑', 'uni-id-unbind-not-supported': '不支持解绑', 'uni-id-unbind-mobile-not-exists': '这是当前唯一登录方式,请绑定手机号后再尝试解绑', - 'uni-id-unbind-password-not-exists': '请先设置密码在尝试解绑' + 'uni-id-unbind-password-not-exists': '请先设置密码在尝试解绑', + 'uni-id-unsupported-request': '不支持的请求方式' } module.exports = { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/captcha.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/captcha.js index 4618fa5de27025243b116cac144618eb0ab37550..0dd620eaf553a6da787ffeb80bc5d43e3a929407 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/captcha.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/captcha.js @@ -39,7 +39,7 @@ async function getNeedCaptcha ({ const { data: recentRecord } = await uniIdLogCollection.where({ - ip: this.getClientInfo().clientIP, + ip: this.getUniversalClientInfo().clientIP, ...userIdentifier, type, create_date: dbCmd.gt(now - limitDuration) @@ -61,7 +61,7 @@ async function verifyCaptcha (params = {}) { } } const payload = await this.uniCaptcha.verify({ - deviceId: this.getClientInfo().deviceId, + deviceId: this.getUniversalClientInfo().deviceId, captcha, scene }) diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/login.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/login.js index 143a92649305ea9ece7ad62788a1f9a9e6a53b6d..09d69ad8c501f6246d612bd6a640d102f22ddae2 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/login.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/login.js @@ -17,7 +17,7 @@ async function realPreLogin (params = {}) { const { user } = params - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const userMatched = await findUser({ userQuery: user, authorizedApp: appId @@ -66,7 +66,7 @@ async function preLoginWithPassword (params = {}) { } = this.config const { clientIP - } = this.getClientInfo() + } = this.getUniversalClientInfo() // 根据ip地址,密码错误次数过多,锁定登录 let loginIPLimit = userRecord.login_ip_limit || [] // 清理无用记录 @@ -79,7 +79,7 @@ async function preLoginWithPassword (params = {}) { } const passwordUtils = new PasswordUtils({ userRecord, - clientInfo: this.getClientInfo(), + clientInfo: this.getUniversalClientInfo(), passwordSecret: this.config.passwordSecret }) @@ -179,7 +179,7 @@ async function postLogin (params = {}) { const { clientIP, uniIdToken - } = this.getClientInfo() + } = this.getUniversalClientInfo() const uid = user._id const updateData = { last_login_date: Date.now(), diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/logout.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/logout.js index dc49fc7c97d71de625d1cbadcb32fb8180008039..1490cb87895599e8fae0481cd739cbd650c60f1f 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/logout.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/logout.js @@ -5,11 +5,11 @@ const { userCollection } = require('../../common/constants') -async function logout() { +async function logout () { const { uniIdToken, deviceId - } = this.getClientInfo() + } = this.getUniversalClientInfo() const { uid } = await this.uniIdCommon.checkToken( @@ -44,4 +44,4 @@ async function logout() { module.exports = { logout -} \ No newline at end of file +} diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/qq.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/qq.js index ebacbb1a99832aa263130ddeeceb78b2867d6e23..7ea612d870e9a45eafc67e68f370516eeb74a82e 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/qq.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/qq.js @@ -5,7 +5,7 @@ const { ERROR } = require('../../common/error') -function getQQPlatform() { +function getQQPlatform () { const platform = this.clientPlatform switch (platform) { case 'app': @@ -18,7 +18,7 @@ function getQQPlatform() { } } -async function saveQQUserKey({ +async function saveQQUserKey ({ openid, sessionKey, // QQ小程序用户sessionKey accessToken, // App端QQ用户accessToken @@ -26,7 +26,7 @@ async function saveQQUserKey({ } = {}) { // 微信公众平台、开放平台refreshToken有效期均为30天(微信没有在网络请求里面返回30天这个值,务必注意未来可能出现调整,需及时更新此处逻辑)。 // 此前QQ开放平台有调整过accessToken的过期时间:[access_token有效期由90天缩短至30天](https://wiki.connect.qq.com/%E3%80%90qq%E4%BA%92%E8%81%94%E3%80%91access_token%E6%9C%89%E6%95%88%E6%9C%9F%E8%B0%83%E6%95%B4) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const qqPlatform = getQQPlatform.call(this) const keyObj = { dcloudAppid: appId, @@ -45,9 +45,9 @@ async function saveQQUserKey({ await this.uniOpenBridge.setUserAccessToken(keyObj, { access_token: accessToken, access_token_expired: accessTokenExpired - }, accessTokenExpired ? - Math.floor((accessTokenExpired - Date.now()) / 1000) : - 30 * 24 * 60 * 60 + }, accessTokenExpired + ? Math.floor((accessTokenExpired - Date.now()) / 1000) + : 30 * 24 * 60 * 60 ) break default: @@ -55,7 +55,7 @@ async function saveQQUserKey({ } } -function generateQQCache({ +function generateQQCache ({ sessionKey, // QQ小程序用户sessionKey accessToken, // App端QQ用户accessToken accessTokenExpired // App端QQ用户accessToken过期时间 @@ -84,11 +84,11 @@ function generateQQCache({ } } -function getQQOpenid({ +function getQQOpenid ({ userRecord } = {}) { const qqPlatform = getQQPlatform.call(this) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const qqOpenidObj = userRecord.qq_openid if (!qqOpenidObj) { return @@ -96,7 +96,7 @@ function getQQOpenid({ return qqOpenidObj[`${qqPlatform}_${appId}`] || qqOpenidObj[qqPlatform] } -async function getQQCacheFallback({ +async function getQQCacheFallback ({ userRecord, key } = {}) { @@ -109,13 +109,13 @@ async function getQQCacheFallback({ return qqCache && qqCache[key] } -async function getQQCache({ +async function getQQCache ({ uid, userRecord, key } = {}) { const qqPlatform = getQQPlatform.call(this) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId if (!userRecord) { const getUserRes = await userCollection.doc(uid).get() diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js index 490d4f20a4a6ba1eca6855bde4731b19566293dd..821e8ca4992062553f7f2f06e885186afb7eb921 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js @@ -24,7 +24,7 @@ async function realPreRegister (params = {}) { } = params const userMatched = await findUser({ userQuery: user, - authorizedApp: this.getClientInfo().appId + authorizedApp: this.getUniversalClientInfo().appId }) if (userMatched.length > 0) { throw { @@ -54,7 +54,7 @@ async function preRegisterWithPassword (params = {}) { user }) const passwordUtils = new PasswordUtils({ - clientInfo: this.getClientInfo(), + clientInfo: this.getUniversalClientInfo(), passwordSecret: this.config.passwordSecret }) const { @@ -99,7 +99,7 @@ async function postRegister (params = {}) { clientIP, osName, uniIdToken - } = this.getClientInfo() + } = this.getUniversalClientInfo() merge(user, extraData) @@ -163,7 +163,7 @@ async function postRegister (params = {}) { if (beforeRegister) { userRecord = await beforeRegister({ userRecord, - clientInfo: this.getClientInfo() + clientInfo: this.getUniversalClientInfo() }) } diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js index 360519a9ca6cdb327a0ed70cbb1e6341a4a6e81e..8948e0e805f70d593d6624b6aa396b816f723ab3 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js @@ -29,7 +29,7 @@ async function preBind ({ } = {}) { const userMatched = await findUser({ userQuery: bindAccount, - authorizedApp: this.getClientInfo().appId + authorizedApp: this.getUniversalClientInfo().appId }) if (userMatched.length > 0) { await this.middleware.uniIdLog({ diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/unified-login.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/unified-login.js index cd758fe5bb718051a416a5a7f7cc7d296a310a25..836d38092bbaf036e5df9ae233578341dbbc4f0a 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/unified-login.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/unified-login.js @@ -17,7 +17,7 @@ async function realPreUnifiedLogin (params = {}) { user, type } = params - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const userMatched = await findUser({ userQuery: user, authorizedApp: appId diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/univerify.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/univerify.js index ba3cb440b7c2591acb09e111165f948f6fe0e23d..33c17c00a23f3d6ad2c5f7abeb288ef807d8ae60 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/univerify.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/univerify.js @@ -13,7 +13,7 @@ async function getPhoneNumber ({ } return uniCloud.getPhoneNumber({ provider: 'univerify', - appid: this.getClientInfo().appId, + appid: this.getUniversalClientInfo().appId, apiKey: univerifyConfig.apiKey, apiSecret: univerifyConfig.apiSecret, // eslint-disable-next-line camelcase diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/verify-code.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/verify-code.js index acebc6bdac3aed5d86c7ba28ae93285888bf5686..b11bc026f119cc7a25f04a7de07d490810c66d44 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/verify-code.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/verify-code.js @@ -23,7 +23,7 @@ async function setVerifyCode ({ scene, code: code || getVerifyCode(), state: 0, - ip: this.getClientInfo().clientIP, + ip: this.getUniversalClientInfo().clientIP, created_date: now, expired_date: now + expiresIn * 1000 } diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/weixin.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/weixin.js index a01435d98030807fb315e8d31feb5f12d1a4c484..619c722cc721cef05301c678283f93005316caf4 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/weixin.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/weixin.js @@ -12,7 +12,7 @@ const { openDataCollection } = require('../../common/constants') -function decryptWeixinData({ +function decryptWeixinData ({ encryptedData, sessionKey, iv @@ -37,9 +37,9 @@ function decryptWeixinData({ return decoded } -function getWeixinPlatform() { +function getWeixinPlatform () { const platform = this.clientPlatform - const userAgent = this.getClientInfo().userAgent + const userAgent = this.getUniversalClientInfo().userAgent switch (platform) { case 'app': case 'app-plus': @@ -54,7 +54,7 @@ function getWeixinPlatform() { } } -async function saveWeixinUserKey({ +async function saveWeixinUserKey ({ openid, sessionKey, // 微信小程序用户sessionKey accessToken, // App端微信用户accessToken @@ -64,7 +64,7 @@ async function saveWeixinUserKey({ // 微信公众平台、开放平台refreshToken有效期均为30天(微信没有在网络请求里面返回30天这个值,务必注意未来可能出现调整,需及时更新此处逻辑)。 // 此前QQ开放平台有调整过accessToken的过期时间:[access_token有效期由90天缩短至30天](https://wiki.connect.qq.com/%E3%80%90qq%E4%BA%92%E8%81%94%E3%80%91access_token%E6%9C%89%E6%95%88%E6%9C%9F%E8%B0%83%E6%95%B4) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const weixinPlatform = getWeixinPlatform.call(this) const keyObj = { dcloudAppid: appId, @@ -91,7 +91,7 @@ async function saveWeixinUserKey({ } } -async function saveSecureNetworkCache({ +async function saveSecureNetworkCache ({ code, openid, unionid, @@ -99,7 +99,7 @@ async function saveSecureNetworkCache({ }) { const { appId - } = this.getClientInfo() + } = this.getUniversalClientInfo() const key = `uni-id:${appId}:weixin-mp:code:${code}:secure-network-cache` const value = JSON.stringify({ openid, @@ -120,7 +120,7 @@ async function saveSecureNetworkCache({ } } -function generateWeixinCache({ +function generateWeixinCache ({ sessionKey, // 微信小程序用户sessionKey accessToken, // App端微信用户accessToken refreshToken, // App端微信用户refreshToken @@ -153,11 +153,11 @@ function generateWeixinCache({ } } -function getWeixinOpenid({ +function getWeixinOpenid ({ userRecord } = {}) { const weixinPlatform = getWeixinPlatform.call(this) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const wxOpenidObj = userRecord.wx_openid if (!wxOpenidObj) { return @@ -165,7 +165,7 @@ function getWeixinOpenid({ return wxOpenidObj[`${weixinPlatform}_${appId}`] || wxOpenidObj[weixinPlatform] } -async function getWeixinCacheFallback({ +async function getWeixinCacheFallback ({ userRecord, key } = {}) { @@ -178,13 +178,13 @@ async function getWeixinCacheFallback({ return weixinCache && weixinCache[key] } -async function getWeixinCache({ +async function getWeixinCache ({ uid, userRecord, key } = {}) { const weixinPlatform = getWeixinPlatform.call(this) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId if (!userRecord) { const getUserRes = await userCollection.doc(uid).get() userRecord = getUserRes.data[0] @@ -212,9 +212,9 @@ async function getWeixinCache({ }) } -async function getWeixinAccessToken() { +async function getWeixinAccessToken () { const weixinPlatform = getWeixinPlatform.call(this) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const cache = await this.uniOpenBridge.getAccessToken({ dcloudAppid: appId, diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/auth.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/auth.js index 4c78b24d56ed0dc30bef102a6a7438b4c1c14a72..1915335d60066599de3abd0bbc094c612ff5148b 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/auth.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/auth.js @@ -2,7 +2,7 @@ module.exports = async function () { if (this.authInfo) { // 多次执行auth时如果第一次成功后续不再执行 return } - const token = this.getUniIdToken() + const token = this.getUniversalUniIdToken() const payload = await this.uniIdCommon.checkToken(token) if (payload.errCode) { throw payload diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/uni-id-log.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/uni-id-log.js index 37ce6552929d1527ab274775e5ae21cf7cd1506f..ca6927d9820a0d36ccf593bffd64d03dffd02b9f 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/uni-id-log.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/uni-id-log.js @@ -19,7 +19,7 @@ module.exports = async function ({ clientIP, deviceId, userAgent - } = this.getClientInfo() + } = this.getUniversalClientInfo() const logData = { appid: appId, device_id: deviceId, diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js index 70dd71ea4f6ab438f53aecba44ae94f918a8d609..7b6ae911ef07baf4c9fdb1b6c694cc1cd490b4e1 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js @@ -79,7 +79,7 @@ module.exports = async function (params = {}) { userQuery: { email }, - authorizedApp: [this.getClientInfo().appId] + authorizedApp: [this.getUniversalClientInfo().appId] }) if (userMatched.length === 0) { throw { @@ -95,7 +95,7 @@ module.exports = async function (params = {}) { passwordHash, version } = new PasswordUtils({ - clientInfo: this.getClientInfo(), + clientInfo: this.getUniversalClientInfo(), passwordSecret: this.config.passwordSecret }).generatePasswordHash({ password diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js index ff055447378a9a162f1ad38f8dd3aad0cbcd576d..05e68bf795c6907306534a796e78e66d80c2f22b 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js @@ -79,7 +79,7 @@ module.exports = async function (params = {}) { userQuery: { mobile }, - authorizedApp: [this.getClientInfo().appId] + authorizedApp: [this.getUniversalClientInfo().appId] }) if (userMatched.length === 0) { throw { @@ -95,7 +95,7 @@ module.exports = async function (params = {}) { passwordHash, version } = new PasswordUtils({ - clientInfo: this.getClientInfo(), + clientInfo: this.getUniversalClientInfo(), passwordSecret: this.config.passwordSecret }).generatePasswordHash({ password diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/update-pwd.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/update-pwd.js index 33cc1b058c3b2c5ae69b8348f20972288f87f627..8a0271847158635ca16205731b795c8d2d71e1ad 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/update-pwd.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/update-pwd.js @@ -33,7 +33,7 @@ module.exports = async function (params = {}) { } = params const passwordUtils = new PasswordUtils({ userRecord, - clientInfo: this.getClientInfo(), + clientInfo: this.getUniversalClientInfo(), passwordSecret: this.config.passwordSecret }) diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/add-user.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/add-user.js index 2c71356214cd8c74c22c282f50fa3e39fffb10f4..7f03fda45326722ffb13c4117ce614dd39b466c0 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/add-user.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/add-user.js @@ -83,7 +83,7 @@ module.exports = async function (params = {}) { } } const passwordUtils = new PasswordUtils({ - clientInfo: this.getClientInfo(), + clientInfo: this.getUniversalClientInfo(), passwordSecret: this.config.passwordSecret }) const { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/update-user.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/update-user.js index 12b073f0d3128bc9a610baf938d5579bba785894..a224a1c4d291295fda470e73a0a509f22929461f 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/update-user.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/update-user.js @@ -107,7 +107,7 @@ module.exports = async function (params = {}) { if (password) { const passwordUtils = new PasswordUtils({ - clientInfo: this.getClientInfo(), + clientInfo: this.getUniversalClientInfo(), passwordSecret: this.config.passwordSecret }) const { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-qq.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-qq.js index 13379d724a5fbb1593b0c3c3d26318133048cf46..fbc406942bae9ab1c307a9a772997e5913c91dbe 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-qq.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-qq.js @@ -56,7 +56,7 @@ module.exports = async function (params = {}) { } = params const { appId - } = this.getClientInfo() + } = this.getUniversalClientInfo() const qqApi = initQQ.call(this) const qqPlatform = getQQPlatform.call(this) let apiName diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin.js index 21d60718300353fafd043f17a10de8055f5b9a8b..58f9ac7f880ce88faf969840260fb7f7feee6f4e 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin.js @@ -44,7 +44,7 @@ module.exports = async function (params = {}) { } = params const { appId - } = this.getClientInfo() + } = this.getUniversalClientInfo() const weixinApi = initWeixin.call(this) const weixinPlatform = getWeixinPlatform.call(this) let apiName diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/register/register-admin.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/register/register-admin.js index 4e2ff4affa03ffed0350e42a63f47ca7eb51c29b..5e122abf93c4da2e0fd115370f3c2cee8375d2ea 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/register/register-admin.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/register/register-admin.js @@ -38,7 +38,7 @@ module.exports = async function (params = {}) { }).limit(1).get() if (getAdminRes.data.length > 0) { const [admin] = getAdminRes.data - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId if (!admin.dcloud_appid || (admin.dcloud_appid && admin.dcloud_appid.includes(appId))) { return { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-qq.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-qq.js index ef801a23fdbd5893abba0729a2e65df80449316f..7a546f918308c1a297ffeecb591f449b1f36eb81 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-qq.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-qq.js @@ -49,7 +49,7 @@ module.exports = async function (params = {}) { accessTokenExpired } = params const qqPlatform = getQQPlatform.call(this) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const qqApi = initQQ.call(this) const clientPlatform = this.clientPlatform const apiName = clientPlatform === 'mp-qq' ? 'code2Session' : 'getOpenidByToken' diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-weixin.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-weixin.js index b0165077c7fc0f140f78b33c070da18fa9065b27..73dcaf86caa72bdad5d48f5c005b099672ea9595 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-weixin.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-weixin.js @@ -34,7 +34,7 @@ module.exports = async function (params = {}) { code } = params const weixinPlatform = getWeixinPlatform.call(this) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const weixinApi = initWeixin.call(this) const clientPlatform = this.clientPlatform diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/unbind-qq.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/unbind-qq.js index c9c80b84f337988a677d5fcac69a302e8ce062a6..0f9e02e7928d11bb515e199e39bd676ba65cbcb3 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/unbind-qq.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/unbind-qq.js @@ -16,7 +16,7 @@ const { */ module.exports = async function () { const { uid } = this.authInfo - const { appId } = this.getClientInfo() + const { appId } = this.getUniversalClientInfo() const qqPlatform = getQQPlatform.call(this) await preUnBind.call(this, { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/refresh-token.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/refresh-token.js index 0c1837e692cbe0a1db8716c45c03f1cc29287cc2..4b0d0a879ccb1529860d25d9a4a940f91c15a4d9 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/refresh-token.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/refresh-token.js @@ -7,7 +7,7 @@ module.exports = async function () { token, tokenExpired } = await this.uniIdCommon.refreshToken({ - token: this.getUniIdToken() + token: this.getUniversalUniIdToken() }) return { errCode: 0, diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/set-push-cid.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/set-push-cid.js index 68c18c62475b29a82fc10746f7786088472fd041..f4196df0d4c566a8c7663fea3e332a2c6d0d5ef6 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/set-push-cid.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/set-push-cid.js @@ -25,7 +25,7 @@ async function setOpendbDevice ({ screenHeight, romName, romVersion - } = this.getClientInfo() + } = this.getUniversalClientInfo() const platform = this.clientPlatform const now = Date.now() @@ -80,7 +80,7 @@ module.exports = async function (params = {}) { deviceId, appId, osName - } = this.getClientInfo() + } = this.getUniversalClientInfo() let platform = this.clientPlatform if (platform === 'app') { platform += osName diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/create-captcha.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/create-captcha.js index 1d77f5e5a3b67ad6953039bcca032d81feaf35c8..9103d5bd3c413b5e3bba360442d20032ec36b162 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/create-captcha.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/create-captcha.js @@ -18,7 +18,7 @@ module.exports = async function (params = {}) { } this.middleware.validate(params, schema) - const deviceId = this.getClientInfo().deviceId + const deviceId = this.getUniversalClientInfo().deviceId const { scene } = params diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/refresh-captcha.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/refresh-captcha.js index e5df246280ade7d3fbc1eed6b01470e1ba11406c..7a1cab9e4c977f71652877838c73c7f9b5d940a1 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/refresh-captcha.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/refresh-captcha.js @@ -18,7 +18,7 @@ module.exports = async function (params = {}) { } this.middleware.validate(params, schema) - const deviceId = this.getClientInfo().deviceId + const deviceId = this.getUniversalClientInfo().deviceId const { scene } = params diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json index b9f6c6d1b367de57e5d8bf4be7800bfdfd8c5ed4..39307ee8191c521e585d1b338aeba3c1e9cbd67f 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json @@ -1,6 +1,6 @@ { "name": "uni-id-co", - "version": "1.0.28", + "version": "1.0.29", "description": "", "main": "index.js", "keywords": [],