防止回调地狱,导致code无限叠加产生鉴权失败的问题
This commit is contained in:
@@ -202,15 +202,19 @@ let timer = {}
|
|||||||
* https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&agentid=AGENTID#wechat_redirect
|
* https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&agentid=AGENTID#wechat_redirect
|
||||||
* @param params
|
* @param params
|
||||||
*/
|
*/
|
||||||
const oauth2Weixin = params => qs.stringifyUrl({
|
const oauth2Weixin = params => {
|
||||||
|
const redirect = qs.parseUrl(location.href)
|
||||||
|
delete redirect.query.code
|
||||||
|
return qs.stringifyUrl({
|
||||||
url: "https://open.weixin.qq.com/connect/oauth2/authorize",
|
url: "https://open.weixin.qq.com/connect/oauth2/authorize",
|
||||||
query: {
|
query: {
|
||||||
response_type: 'code',
|
response_type: 'code',
|
||||||
redirect_uri: encodeURIComponent(location.href),
|
redirect_uri: qs.stringifyUrl(redirect),
|
||||||
...params
|
...params
|
||||||
},
|
},
|
||||||
fragmentIdentifier: "wechat_redirect"
|
fragmentIdentifier: "wechat_redirect"
|
||||||
})
|
})
|
||||||
|
}
|
||||||
export const wxwork = {
|
export const wxwork = {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
agentSignURL: "",
|
agentSignURL: "",
|
||||||
@@ -287,12 +291,9 @@ export const wxwork = {
|
|||||||
dispatch("agentSign", {corpId, suiteId}).then(() => excute(true)).then(() => resolve())
|
dispatch("agentSign", {corpId, suiteId}).then(() => excute(true)).then(() => resolve())
|
||||||
} else reject("URL缺少必要参数(corpId)")
|
} else reject("URL缺少必要参数(corpId)")
|
||||||
})
|
})
|
||||||
} else new Promise((resolve, reject) => {
|
} else new Promise(() => {
|
||||||
const {appid} = params
|
|
||||||
if (!!appid) {
|
|
||||||
const oauthURL = oauth2Weixin(params)
|
const oauthURL = oauth2Weixin(params)
|
||||||
location.replace(oauthURL)
|
location.replace(oauthURL)
|
||||||
} else reject("URL缺少必要参数(appid)")
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return excute()
|
return excute()
|
||||||
|
|||||||
Reference in New Issue
Block a user