提交 d2a5a7af 编写于 作者: C chenruilong

feat: uni-id-co 支持 URL 化

上级 bd689925
## 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) ## 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 升级密码加密算法,支持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) ## 1.0.27(2022-10-26)
- uni-id-co 新增 secureNetworkHandshakeByWeixin 接口,用于建立和微信小程序的安全网络连接 - uni-id-co 新增 secureNetworkHandshakeByWeixin 接口,用于建立和微信小程序的安全网络连接
## 1.0.26(2022-10-18) ## 1.0.26(2022-10-18)
......
{ {
"id": "uni-id-pages", "id": "uni-id-pages",
"displayName": "uni-id-pages", "displayName": "uni-id-pages",
"version": "1.0.28", "version": "1.0.29",
"description": "云端一体简单、统一、可扩展的用户中心页面模版", "description": "云端一体简单、统一、可扩展的用户中心页面模版",
"keywords": [ "keywords": [
"用户管理", "用户管理",
......
...@@ -35,7 +35,8 @@ const ERROR = { ...@@ -35,7 +35,8 @@ const ERROR = {
UNBIND_NOT_SUPPORTED: 'uni-id-unbind-not-supported', UNBIND_NOT_SUPPORTED: 'uni-id-unbind-not-supported',
UNBIND_UNIQUE_LOGIN: 'uni-id-unbind-unique-login', UNBIND_UNIQUE_LOGIN: 'uni-id-unbind-unique-login',
UNBIND_PASSWORD_NOT_EXISTS: 'uni-id-unbind-password-not-exists', 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) { function isUniIdError (errCode) {
......
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
...@@ -12,6 +12,7 @@ const { ...@@ -12,6 +12,7 @@ const {
isUniIdError isUniIdError
} = require('./common/error') } = require('./common/error')
const middleware = require('./middleware/index') const middleware = require('./middleware/index')
const universal = require('./common/universal')
const { const {
registerAdmin, registerAdmin,
...@@ -81,7 +82,10 @@ const { ...@@ -81,7 +82,10 @@ const {
module.exports = { module.exports = {
async _before () { async _before () {
const clientInfo = this.getClientInfo() // 支持 callFunction 与 URL化
universal.call(this)
const clientInfo = this.getUniversalClientInfo()
/** /**
* 检查clientInfo,无appId和uniPlatform时本云对象无法正常运行 * 检查clientInfo,无appId和uniPlatform时本云对象无法正常运行
* 此外需要保证用到的clientInfo字段均经过类型检查 * 此外需要保证用到的clientInfo字段均经过类型检查
......
...@@ -40,7 +40,8 @@ const sentence = { ...@@ -40,7 +40,8 @@ const sentence = {
'uni-id-unbind-failed': 'Please bind first and then unbind', 'uni-id-unbind-failed': 'Please bind first and then unbind',
'uni-id-unbind-not-supported': 'Unbinding is not supported', '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-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 = { module.exports = {
......
...@@ -40,7 +40,8 @@ const sentence = { ...@@ -40,7 +40,8 @@ const sentence = {
'uni-id-unbind-failed': '请先绑定后再解绑', 'uni-id-unbind-failed': '请先绑定后再解绑',
'uni-id-unbind-not-supported': '不支持解绑', 'uni-id-unbind-not-supported': '不支持解绑',
'uni-id-unbind-mobile-not-exists': '这是当前唯一登录方式,请绑定手机号后再尝试解绑', 'uni-id-unbind-mobile-not-exists': '这是当前唯一登录方式,请绑定手机号后再尝试解绑',
'uni-id-unbind-password-not-exists': '请先设置密码在尝试解绑' 'uni-id-unbind-password-not-exists': '请先设置密码在尝试解绑',
'uni-id-unsupported-request': '不支持的请求方式'
} }
module.exports = { module.exports = {
......
...@@ -39,7 +39,7 @@ async function getNeedCaptcha ({ ...@@ -39,7 +39,7 @@ async function getNeedCaptcha ({
const { const {
data: recentRecord data: recentRecord
} = await uniIdLogCollection.where({ } = await uniIdLogCollection.where({
ip: this.getClientInfo().clientIP, ip: this.getUniversalClientInfo().clientIP,
...userIdentifier, ...userIdentifier,
type, type,
create_date: dbCmd.gt(now - limitDuration) create_date: dbCmd.gt(now - limitDuration)
...@@ -61,7 +61,7 @@ async function verifyCaptcha (params = {}) { ...@@ -61,7 +61,7 @@ async function verifyCaptcha (params = {}) {
} }
} }
const payload = await this.uniCaptcha.verify({ const payload = await this.uniCaptcha.verify({
deviceId: this.getClientInfo().deviceId, deviceId: this.getUniversalClientInfo().deviceId,
captcha, captcha,
scene scene
}) })
......
...@@ -17,7 +17,7 @@ async function realPreLogin (params = {}) { ...@@ -17,7 +17,7 @@ async function realPreLogin (params = {}) {
const { const {
user user
} = params } = params
const appId = this.getClientInfo().appId const appId = this.getUniversalClientInfo().appId
const userMatched = await findUser({ const userMatched = await findUser({
userQuery: user, userQuery: user,
authorizedApp: appId authorizedApp: appId
...@@ -66,7 +66,7 @@ async function preLoginWithPassword (params = {}) { ...@@ -66,7 +66,7 @@ async function preLoginWithPassword (params = {}) {
} = this.config } = this.config
const { const {
clientIP clientIP
} = this.getClientInfo() } = this.getUniversalClientInfo()
// 根据ip地址,密码错误次数过多,锁定登录 // 根据ip地址,密码错误次数过多,锁定登录
let loginIPLimit = userRecord.login_ip_limit || [] let loginIPLimit = userRecord.login_ip_limit || []
// 清理无用记录 // 清理无用记录
...@@ -79,7 +79,7 @@ async function preLoginWithPassword (params = {}) { ...@@ -79,7 +79,7 @@ async function preLoginWithPassword (params = {}) {
} }
const passwordUtils = new PasswordUtils({ const passwordUtils = new PasswordUtils({
userRecord, userRecord,
clientInfo: this.getClientInfo(), clientInfo: this.getUniversalClientInfo(),
passwordSecret: this.config.passwordSecret passwordSecret: this.config.passwordSecret
}) })
...@@ -179,7 +179,7 @@ async function postLogin (params = {}) { ...@@ -179,7 +179,7 @@ async function postLogin (params = {}) {
const { const {
clientIP, clientIP,
uniIdToken uniIdToken
} = this.getClientInfo() } = this.getUniversalClientInfo()
const uid = user._id const uid = user._id
const updateData = { const updateData = {
last_login_date: Date.now(), last_login_date: Date.now(),
......
...@@ -5,11 +5,11 @@ const { ...@@ -5,11 +5,11 @@ const {
userCollection userCollection
} = require('../../common/constants') } = require('../../common/constants')
async function logout() { async function logout () {
const { const {
uniIdToken, uniIdToken,
deviceId deviceId
} = this.getClientInfo() } = this.getUniversalClientInfo()
const { const {
uid uid
} = await this.uniIdCommon.checkToken( } = await this.uniIdCommon.checkToken(
......
...@@ -5,7 +5,7 @@ const { ...@@ -5,7 +5,7 @@ const {
ERROR ERROR
} = require('../../common/error') } = require('../../common/error')
function getQQPlatform() { function getQQPlatform () {
const platform = this.clientPlatform const platform = this.clientPlatform
switch (platform) { switch (platform) {
case 'app': case 'app':
...@@ -18,7 +18,7 @@ function getQQPlatform() { ...@@ -18,7 +18,7 @@ function getQQPlatform() {
} }
} }
async function saveQQUserKey({ async function saveQQUserKey ({
openid, openid,
sessionKey, // QQ小程序用户sessionKey sessionKey, // QQ小程序用户sessionKey
accessToken, // App端QQ用户accessToken accessToken, // App端QQ用户accessToken
...@@ -26,7 +26,7 @@ async function saveQQUserKey({ ...@@ -26,7 +26,7 @@ async function saveQQUserKey({
} = {}) { } = {}) {
// 微信公众平台、开放平台refreshToken有效期均为30天(微信没有在网络请求里面返回30天这个值,务必注意未来可能出现调整,需及时更新此处逻辑)。 // 微信公众平台、开放平台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) // 此前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 qqPlatform = getQQPlatform.call(this)
const keyObj = { const keyObj = {
dcloudAppid: appId, dcloudAppid: appId,
...@@ -45,9 +45,9 @@ async function saveQQUserKey({ ...@@ -45,9 +45,9 @@ async function saveQQUserKey({
await this.uniOpenBridge.setUserAccessToken(keyObj, { await this.uniOpenBridge.setUserAccessToken(keyObj, {
access_token: accessToken, access_token: accessToken,
access_token_expired: accessTokenExpired access_token_expired: accessTokenExpired
}, accessTokenExpired ? }, accessTokenExpired
Math.floor((accessTokenExpired - Date.now()) / 1000) : ? Math.floor((accessTokenExpired - Date.now()) / 1000)
30 * 24 * 60 * 60 : 30 * 24 * 60 * 60
) )
break break
default: default:
...@@ -55,7 +55,7 @@ async function saveQQUserKey({ ...@@ -55,7 +55,7 @@ async function saveQQUserKey({
} }
} }
function generateQQCache({ function generateQQCache ({
sessionKey, // QQ小程序用户sessionKey sessionKey, // QQ小程序用户sessionKey
accessToken, // App端QQ用户accessToken accessToken, // App端QQ用户accessToken
accessTokenExpired // App端QQ用户accessToken过期时间 accessTokenExpired // App端QQ用户accessToken过期时间
...@@ -84,11 +84,11 @@ function generateQQCache({ ...@@ -84,11 +84,11 @@ function generateQQCache({
} }
} }
function getQQOpenid({ function getQQOpenid ({
userRecord userRecord
} = {}) { } = {}) {
const qqPlatform = getQQPlatform.call(this) const qqPlatform = getQQPlatform.call(this)
const appId = this.getClientInfo().appId const appId = this.getUniversalClientInfo().appId
const qqOpenidObj = userRecord.qq_openid const qqOpenidObj = userRecord.qq_openid
if (!qqOpenidObj) { if (!qqOpenidObj) {
return return
...@@ -96,7 +96,7 @@ function getQQOpenid({ ...@@ -96,7 +96,7 @@ function getQQOpenid({
return qqOpenidObj[`${qqPlatform}_${appId}`] || qqOpenidObj[qqPlatform] return qqOpenidObj[`${qqPlatform}_${appId}`] || qqOpenidObj[qqPlatform]
} }
async function getQQCacheFallback({ async function getQQCacheFallback ({
userRecord, userRecord,
key key
} = {}) { } = {}) {
...@@ -109,13 +109,13 @@ async function getQQCacheFallback({ ...@@ -109,13 +109,13 @@ async function getQQCacheFallback({
return qqCache && qqCache[key] return qqCache && qqCache[key]
} }
async function getQQCache({ async function getQQCache ({
uid, uid,
userRecord, userRecord,
key key
} = {}) { } = {}) {
const qqPlatform = getQQPlatform.call(this) const qqPlatform = getQQPlatform.call(this)
const appId = this.getClientInfo().appId const appId = this.getUniversalClientInfo().appId
if (!userRecord) { if (!userRecord) {
const getUserRes = await userCollection.doc(uid).get() const getUserRes = await userCollection.doc(uid).get()
......
...@@ -24,7 +24,7 @@ async function realPreRegister (params = {}) { ...@@ -24,7 +24,7 @@ async function realPreRegister (params = {}) {
} = params } = params
const userMatched = await findUser({ const userMatched = await findUser({
userQuery: user, userQuery: user,
authorizedApp: this.getClientInfo().appId authorizedApp: this.getUniversalClientInfo().appId
}) })
if (userMatched.length > 0) { if (userMatched.length > 0) {
throw { throw {
...@@ -54,7 +54,7 @@ async function preRegisterWithPassword (params = {}) { ...@@ -54,7 +54,7 @@ async function preRegisterWithPassword (params = {}) {
user user
}) })
const passwordUtils = new PasswordUtils({ const passwordUtils = new PasswordUtils({
clientInfo: this.getClientInfo(), clientInfo: this.getUniversalClientInfo(),
passwordSecret: this.config.passwordSecret passwordSecret: this.config.passwordSecret
}) })
const { const {
...@@ -99,7 +99,7 @@ async function postRegister (params = {}) { ...@@ -99,7 +99,7 @@ async function postRegister (params = {}) {
clientIP, clientIP,
osName, osName,
uniIdToken uniIdToken
} = this.getClientInfo() } = this.getUniversalClientInfo()
merge(user, extraData) merge(user, extraData)
...@@ -163,7 +163,7 @@ async function postRegister (params = {}) { ...@@ -163,7 +163,7 @@ async function postRegister (params = {}) {
if (beforeRegister) { if (beforeRegister) {
userRecord = await beforeRegister({ userRecord = await beforeRegister({
userRecord, userRecord,
clientInfo: this.getClientInfo() clientInfo: this.getUniversalClientInfo()
}) })
} }
......
...@@ -29,7 +29,7 @@ async function preBind ({ ...@@ -29,7 +29,7 @@ async function preBind ({
} = {}) { } = {}) {
const userMatched = await findUser({ const userMatched = await findUser({
userQuery: bindAccount, userQuery: bindAccount,
authorizedApp: this.getClientInfo().appId authorizedApp: this.getUniversalClientInfo().appId
}) })
if (userMatched.length > 0) { if (userMatched.length > 0) {
await this.middleware.uniIdLog({ await this.middleware.uniIdLog({
......
...@@ -17,7 +17,7 @@ async function realPreUnifiedLogin (params = {}) { ...@@ -17,7 +17,7 @@ async function realPreUnifiedLogin (params = {}) {
user, user,
type type
} = params } = params
const appId = this.getClientInfo().appId const appId = this.getUniversalClientInfo().appId
const userMatched = await findUser({ const userMatched = await findUser({
userQuery: user, userQuery: user,
authorizedApp: appId authorizedApp: appId
......
...@@ -13,7 +13,7 @@ async function getPhoneNumber ({ ...@@ -13,7 +13,7 @@ async function getPhoneNumber ({
} }
return uniCloud.getPhoneNumber({ return uniCloud.getPhoneNumber({
provider: 'univerify', provider: 'univerify',
appid: this.getClientInfo().appId, appid: this.getUniversalClientInfo().appId,
apiKey: univerifyConfig.apiKey, apiKey: univerifyConfig.apiKey,
apiSecret: univerifyConfig.apiSecret, apiSecret: univerifyConfig.apiSecret,
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
......
...@@ -23,7 +23,7 @@ async function setVerifyCode ({ ...@@ -23,7 +23,7 @@ async function setVerifyCode ({
scene, scene,
code: code || getVerifyCode(), code: code || getVerifyCode(),
state: 0, state: 0,
ip: this.getClientInfo().clientIP, ip: this.getUniversalClientInfo().clientIP,
created_date: now, created_date: now,
expired_date: now + expiresIn * 1000 expired_date: now + expiresIn * 1000
} }
......
...@@ -12,7 +12,7 @@ const { ...@@ -12,7 +12,7 @@ const {
openDataCollection openDataCollection
} = require('../../common/constants') } = require('../../common/constants')
function decryptWeixinData({ function decryptWeixinData ({
encryptedData, encryptedData,
sessionKey, sessionKey,
iv iv
...@@ -37,9 +37,9 @@ function decryptWeixinData({ ...@@ -37,9 +37,9 @@ function decryptWeixinData({
return decoded return decoded
} }
function getWeixinPlatform() { function getWeixinPlatform () {
const platform = this.clientPlatform const platform = this.clientPlatform
const userAgent = this.getClientInfo().userAgent const userAgent = this.getUniversalClientInfo().userAgent
switch (platform) { switch (platform) {
case 'app': case 'app':
case 'app-plus': case 'app-plus':
...@@ -54,7 +54,7 @@ function getWeixinPlatform() { ...@@ -54,7 +54,7 @@ function getWeixinPlatform() {
} }
} }
async function saveWeixinUserKey({ async function saveWeixinUserKey ({
openid, openid,
sessionKey, // 微信小程序用户sessionKey sessionKey, // 微信小程序用户sessionKey
accessToken, // App端微信用户accessToken accessToken, // App端微信用户accessToken
...@@ -64,7 +64,7 @@ async function saveWeixinUserKey({ ...@@ -64,7 +64,7 @@ async function saveWeixinUserKey({
// 微信公众平台、开放平台refreshToken有效期均为30天(微信没有在网络请求里面返回30天这个值,务必注意未来可能出现调整,需及时更新此处逻辑)。 // 微信公众平台、开放平台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) // 此前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 weixinPlatform = getWeixinPlatform.call(this)
const keyObj = { const keyObj = {
dcloudAppid: appId, dcloudAppid: appId,
...@@ -91,7 +91,7 @@ async function saveWeixinUserKey({ ...@@ -91,7 +91,7 @@ async function saveWeixinUserKey({
} }
} }
async function saveSecureNetworkCache({ async function saveSecureNetworkCache ({
code, code,
openid, openid,
unionid, unionid,
...@@ -99,7 +99,7 @@ async function saveSecureNetworkCache({ ...@@ -99,7 +99,7 @@ async function saveSecureNetworkCache({
}) { }) {
const { const {
appId appId
} = this.getClientInfo() } = this.getUniversalClientInfo()
const key = `uni-id:${appId}:weixin-mp:code:${code}:secure-network-cache` const key = `uni-id:${appId}:weixin-mp:code:${code}:secure-network-cache`
const value = JSON.stringify({ const value = JSON.stringify({
openid, openid,
...@@ -120,7 +120,7 @@ async function saveSecureNetworkCache({ ...@@ -120,7 +120,7 @@ async function saveSecureNetworkCache({
} }
} }
function generateWeixinCache({ function generateWeixinCache ({
sessionKey, // 微信小程序用户sessionKey sessionKey, // 微信小程序用户sessionKey
accessToken, // App端微信用户accessToken accessToken, // App端微信用户accessToken
refreshToken, // App端微信用户refreshToken refreshToken, // App端微信用户refreshToken
...@@ -153,11 +153,11 @@ function generateWeixinCache({ ...@@ -153,11 +153,11 @@ function generateWeixinCache({
} }
} }
function getWeixinOpenid({ function getWeixinOpenid ({
userRecord userRecord
} = {}) { } = {}) {
const weixinPlatform = getWeixinPlatform.call(this) const weixinPlatform = getWeixinPlatform.call(this)
const appId = this.getClientInfo().appId const appId = this.getUniversalClientInfo().appId
const wxOpenidObj = userRecord.wx_openid const wxOpenidObj = userRecord.wx_openid
if (!wxOpenidObj) { if (!wxOpenidObj) {
return return
...@@ -165,7 +165,7 @@ function getWeixinOpenid({ ...@@ -165,7 +165,7 @@ function getWeixinOpenid({
return wxOpenidObj[`${weixinPlatform}_${appId}`] || wxOpenidObj[weixinPlatform] return wxOpenidObj[`${weixinPlatform}_${appId}`] || wxOpenidObj[weixinPlatform]
} }
async function getWeixinCacheFallback({ async function getWeixinCacheFallback ({
userRecord, userRecord,
key key
} = {}) { } = {}) {
...@@ -178,13 +178,13 @@ async function getWeixinCacheFallback({ ...@@ -178,13 +178,13 @@ async function getWeixinCacheFallback({
return weixinCache && weixinCache[key] return weixinCache && weixinCache[key]
} }
async function getWeixinCache({ async function getWeixinCache ({
uid, uid,
userRecord, userRecord,
key key
} = {}) { } = {}) {
const weixinPlatform = getWeixinPlatform.call(this) const weixinPlatform = getWeixinPlatform.call(this)
const appId = this.getClientInfo().appId const appId = this.getUniversalClientInfo().appId
if (!userRecord) { if (!userRecord) {
const getUserRes = await userCollection.doc(uid).get() const getUserRes = await userCollection.doc(uid).get()
userRecord = getUserRes.data[0] userRecord = getUserRes.data[0]
...@@ -212,9 +212,9 @@ async function getWeixinCache({ ...@@ -212,9 +212,9 @@ async function getWeixinCache({
}) })
} }
async function getWeixinAccessToken() { async function getWeixinAccessToken () {
const weixinPlatform = getWeixinPlatform.call(this) const weixinPlatform = getWeixinPlatform.call(this)
const appId = this.getClientInfo().appId const appId = this.getUniversalClientInfo().appId
const cache = await this.uniOpenBridge.getAccessToken({ const cache = await this.uniOpenBridge.getAccessToken({
dcloudAppid: appId, dcloudAppid: appId,
......
...@@ -2,7 +2,7 @@ module.exports = async function () { ...@@ -2,7 +2,7 @@ module.exports = async function () {
if (this.authInfo) { // 多次执行auth时如果第一次成功后续不再执行 if (this.authInfo) { // 多次执行auth时如果第一次成功后续不再执行
return return
} }
const token = this.getUniIdToken() const token = this.getUniversalUniIdToken()
const payload = await this.uniIdCommon.checkToken(token) const payload = await this.uniIdCommon.checkToken(token)
if (payload.errCode) { if (payload.errCode) {
throw payload throw payload
......
...@@ -19,7 +19,7 @@ module.exports = async function ({ ...@@ -19,7 +19,7 @@ module.exports = async function ({
clientIP, clientIP,
deviceId, deviceId,
userAgent userAgent
} = this.getClientInfo() } = this.getUniversalClientInfo()
const logData = { const logData = {
appid: appId, appid: appId,
device_id: deviceId, device_id: deviceId,
......
...@@ -79,7 +79,7 @@ module.exports = async function (params = {}) { ...@@ -79,7 +79,7 @@ module.exports = async function (params = {}) {
userQuery: { userQuery: {
email email
}, },
authorizedApp: [this.getClientInfo().appId] authorizedApp: [this.getUniversalClientInfo().appId]
}) })
if (userMatched.length === 0) { if (userMatched.length === 0) {
throw { throw {
...@@ -95,7 +95,7 @@ module.exports = async function (params = {}) { ...@@ -95,7 +95,7 @@ module.exports = async function (params = {}) {
passwordHash, passwordHash,
version version
} = new PasswordUtils({ } = new PasswordUtils({
clientInfo: this.getClientInfo(), clientInfo: this.getUniversalClientInfo(),
passwordSecret: this.config.passwordSecret passwordSecret: this.config.passwordSecret
}).generatePasswordHash({ }).generatePasswordHash({
password password
......
...@@ -79,7 +79,7 @@ module.exports = async function (params = {}) { ...@@ -79,7 +79,7 @@ module.exports = async function (params = {}) {
userQuery: { userQuery: {
mobile mobile
}, },
authorizedApp: [this.getClientInfo().appId] authorizedApp: [this.getUniversalClientInfo().appId]
}) })
if (userMatched.length === 0) { if (userMatched.length === 0) {
throw { throw {
...@@ -95,7 +95,7 @@ module.exports = async function (params = {}) { ...@@ -95,7 +95,7 @@ module.exports = async function (params = {}) {
passwordHash, passwordHash,
version version
} = new PasswordUtils({ } = new PasswordUtils({
clientInfo: this.getClientInfo(), clientInfo: this.getUniversalClientInfo(),
passwordSecret: this.config.passwordSecret passwordSecret: this.config.passwordSecret
}).generatePasswordHash({ }).generatePasswordHash({
password password
......
...@@ -33,7 +33,7 @@ module.exports = async function (params = {}) { ...@@ -33,7 +33,7 @@ module.exports = async function (params = {}) {
} = params } = params
const passwordUtils = new PasswordUtils({ const passwordUtils = new PasswordUtils({
userRecord, userRecord,
clientInfo: this.getClientInfo(), clientInfo: this.getUniversalClientInfo(),
passwordSecret: this.config.passwordSecret passwordSecret: this.config.passwordSecret
}) })
......
...@@ -83,7 +83,7 @@ module.exports = async function (params = {}) { ...@@ -83,7 +83,7 @@ module.exports = async function (params = {}) {
} }
} }
const passwordUtils = new PasswordUtils({ const passwordUtils = new PasswordUtils({
clientInfo: this.getClientInfo(), clientInfo: this.getUniversalClientInfo(),
passwordSecret: this.config.passwordSecret passwordSecret: this.config.passwordSecret
}) })
const { const {
......
...@@ -107,7 +107,7 @@ module.exports = async function (params = {}) { ...@@ -107,7 +107,7 @@ module.exports = async function (params = {}) {
if (password) { if (password) {
const passwordUtils = new PasswordUtils({ const passwordUtils = new PasswordUtils({
clientInfo: this.getClientInfo(), clientInfo: this.getUniversalClientInfo(),
passwordSecret: this.config.passwordSecret passwordSecret: this.config.passwordSecret
}) })
const { const {
......
...@@ -56,7 +56,7 @@ module.exports = async function (params = {}) { ...@@ -56,7 +56,7 @@ module.exports = async function (params = {}) {
} = params } = params
const { const {
appId appId
} = this.getClientInfo() } = this.getUniversalClientInfo()
const qqApi = initQQ.call(this) const qqApi = initQQ.call(this)
const qqPlatform = getQQPlatform.call(this) const qqPlatform = getQQPlatform.call(this)
let apiName let apiName
......
...@@ -44,7 +44,7 @@ module.exports = async function (params = {}) { ...@@ -44,7 +44,7 @@ module.exports = async function (params = {}) {
} = params } = params
const { const {
appId appId
} = this.getClientInfo() } = this.getUniversalClientInfo()
const weixinApi = initWeixin.call(this) const weixinApi = initWeixin.call(this)
const weixinPlatform = getWeixinPlatform.call(this) const weixinPlatform = getWeixinPlatform.call(this)
let apiName let apiName
......
...@@ -38,7 +38,7 @@ module.exports = async function (params = {}) { ...@@ -38,7 +38,7 @@ module.exports = async function (params = {}) {
}).limit(1).get() }).limit(1).get()
if (getAdminRes.data.length > 0) { if (getAdminRes.data.length > 0) {
const [admin] = getAdminRes.data 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))) { if (!admin.dcloud_appid || (admin.dcloud_appid && admin.dcloud_appid.includes(appId))) {
return { return {
......
...@@ -49,7 +49,7 @@ module.exports = async function (params = {}) { ...@@ -49,7 +49,7 @@ module.exports = async function (params = {}) {
accessTokenExpired accessTokenExpired
} = params } = params
const qqPlatform = getQQPlatform.call(this) const qqPlatform = getQQPlatform.call(this)
const appId = this.getClientInfo().appId const appId = this.getUniversalClientInfo().appId
const qqApi = initQQ.call(this) const qqApi = initQQ.call(this)
const clientPlatform = this.clientPlatform const clientPlatform = this.clientPlatform
const apiName = clientPlatform === 'mp-qq' ? 'code2Session' : 'getOpenidByToken' const apiName = clientPlatform === 'mp-qq' ? 'code2Session' : 'getOpenidByToken'
......
...@@ -34,7 +34,7 @@ module.exports = async function (params = {}) { ...@@ -34,7 +34,7 @@ module.exports = async function (params = {}) {
code code
} = params } = params
const weixinPlatform = getWeixinPlatform.call(this) const weixinPlatform = getWeixinPlatform.call(this)
const appId = this.getClientInfo().appId const appId = this.getUniversalClientInfo().appId
const weixinApi = initWeixin.call(this) const weixinApi = initWeixin.call(this)
const clientPlatform = this.clientPlatform const clientPlatform = this.clientPlatform
......
...@@ -16,7 +16,7 @@ const { ...@@ -16,7 +16,7 @@ const {
*/ */
module.exports = async function () { module.exports = async function () {
const { uid } = this.authInfo const { uid } = this.authInfo
const { appId } = this.getClientInfo() const { appId } = this.getUniversalClientInfo()
const qqPlatform = getQQPlatform.call(this) const qqPlatform = getQQPlatform.call(this)
await preUnBind.call(this, { await preUnBind.call(this, {
......
...@@ -7,7 +7,7 @@ module.exports = async function () { ...@@ -7,7 +7,7 @@ module.exports = async function () {
token, token,
tokenExpired tokenExpired
} = await this.uniIdCommon.refreshToken({ } = await this.uniIdCommon.refreshToken({
token: this.getUniIdToken() token: this.getUniversalUniIdToken()
}) })
return { return {
errCode: 0, errCode: 0,
......
...@@ -25,7 +25,7 @@ async function setOpendbDevice ({ ...@@ -25,7 +25,7 @@ async function setOpendbDevice ({
screenHeight, screenHeight,
romName, romName,
romVersion romVersion
} = this.getClientInfo() } = this.getUniversalClientInfo()
const platform = this.clientPlatform const platform = this.clientPlatform
const now = Date.now() const now = Date.now()
...@@ -80,7 +80,7 @@ module.exports = async function (params = {}) { ...@@ -80,7 +80,7 @@ module.exports = async function (params = {}) {
deviceId, deviceId,
appId, appId,
osName osName
} = this.getClientInfo() } = this.getUniversalClientInfo()
let platform = this.clientPlatform let platform = this.clientPlatform
if (platform === 'app') { if (platform === 'app') {
platform += osName platform += osName
......
...@@ -18,7 +18,7 @@ module.exports = async function (params = {}) { ...@@ -18,7 +18,7 @@ module.exports = async function (params = {}) {
} }
this.middleware.validate(params, schema) this.middleware.validate(params, schema)
const deviceId = this.getClientInfo().deviceId const deviceId = this.getUniversalClientInfo().deviceId
const { const {
scene scene
} = params } = params
......
...@@ -18,7 +18,7 @@ module.exports = async function (params = {}) { ...@@ -18,7 +18,7 @@ module.exports = async function (params = {}) {
} }
this.middleware.validate(params, schema) this.middleware.validate(params, schema)
const deviceId = this.getClientInfo().deviceId const deviceId = this.getUniversalClientInfo().deviceId
const { const {
scene scene
} = params } = params
......
{ {
"name": "uni-id-co", "name": "uni-id-co",
"version": "1.0.28", "version": "1.0.29",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"keywords": [], "keywords": [],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册