提交 f029334f 编写于 作者: 雪洛's avatar 雪洛

feat: remove getH5WeixinConfig

上级 a6c3dde8
module.exports = {
beforeRegister: function({
userRecord,
clientInfo
} = {}){
console.log(clientInfo);
userRecord.role = ['test-role']
return userRecord
}
}
\ No newline at end of file
......@@ -54,8 +54,7 @@ const {
} = require('./module/verify/index')
const {
refreshToken,
setPushCid,
getH5WeixinConfig
setPushCid
} = require('./module/utils/index')
const {
getInvitedUser,
......@@ -490,13 +489,5 @@ module.exports = {
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#get-supported-login-type
* @returns
*/
getSupportedLoginType,
/**
* 获取微信公众号config参数
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#get-h5-weixin-config
* @param {object} params
* @param {string} params.url 当前页面url不带hash部分
* @returns
*/
getH5WeixinConfig
getSupportedLoginType
}
const {
getWeixinPlatform
} = require('../../lib/utils/weixin')
const {
getNonceStr
} = require('../../common/utils')
const {
createHash
} = require('crypto')
/**
* 获取微信公众号config参数
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#get-h5-weixin-config
* @param {object} params
* @param {string} params.url 当前页面url不带hash部分
* @returns
*/
module.exports = async function (params) {
const schema = {
url: 'string'
}
this.middleware.validate(params, schema)
const {
url
} = params
const oauthConfig = this.configUtils.getOauthConfig({
provider: 'weixin'
})
const {
appId
} = this.getClientInfo()
const weixinPlatform = getWeixinPlatform.call(this)
const getTicketRes = await this.uniOpenBridge.getTicket({
dcloudAppid: appId,
platform: weixinPlatform + '-weixin'
})
if (!getTicketRes) {
throw new Error('Wechat official account ticket not found, please referer to: https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#login-by-weixin-h5')
}
const ticket = getTicketRes.ticket
const signContent = {
jsapi_ticket: ticket,
noncestr: getNonceStr(),
timestamp: Math.floor(Date.now() / 1000),
url: url.split('#')[0]
}
const signStr = Object.keys(signContent).sort().reduce(function (str, key) {
return str + key + '=' + signContent[key] + '&'
}, '').replace(/&$/, '')
const signature = createHash('sha1').update(signStr, 'utf8').digest('hex')
return {
errCode: 0,
appId: oauthConfig.appid, // 公众号的唯一标识
timestamp: signContent.timestamp, // 生成签名的时间戳
nonceStr: signContent.noncestr, // 生成签名的随机串
signature // 签名
}
}
module.exports = {
refreshToken: require('./refresh-token'),
setPushCid: require('./set-push-cid'),
getH5WeixinConfig: require('./get-h5-weixin-config')
setPushCid: require('./set-push-cid')
}
const clientInfo = {
"PLATFORM": "web",
"OS": "ios",
"APPID": "__UNI__ECAF623",
"DEVICEID": "16558192370391366615",
"scene": 1001,
"appId": "__UNI__ECAF623",
"appLanguage": "zh-Hans",
"appName": "uni-id-pages",
"appVersion": "1.0.0",
"appVersionCode": "100",
"browserName": "safari",
"browserVersion": "13.0.3",
"deviceId": "16558192370391366615",
"deviceModel": "iPhone",
"deviceOrientation": "portrait",
"devicePixelRatio": 2.0000000298023224,
"deviceType": "phone",
"hostLanguage": "en-US",
"hostName": "safari",
"hostVersion": "13.0.3",
"osName": "ios",
"osVersion": "13.2.3",
"safeArea": {
"left": 0,
"right": 375,
"top": 0,
"bottom": 667,
"width": 375,
"height": 667
},
"safeAreaInsets": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0
},
"screenHeight": 667,
"screenWidth": 375,
"statusBarHeight": 0,
"ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",
"uniCompileVersion": "3.5.4",
"uniPlatform": "web",
"uniRuntimeVersion": "3.5.4",
"windowBottom": 0,
"windowHeight": 667,
"windowTop": 0,
"windowWidth": 375,
"locale": "zh-Hans",
"LOCALE": "zh-Hans"
}
registerUser({
"username": "qqq2",
"nickname": "",
"password": "qqq11122",
"password2": "qqq11122",
"captcha": "3IPP"
})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册