修正了weChatLoginGrant对state为空的处理逻辑

This commit is contained in:
Xu Chang 2024-05-23 00:47:40 +08:00
parent 9e6922e468
commit 421a168efc
2 changed files with 6 additions and 4 deletions

View File

@ -20,6 +20,7 @@ function Grant(props) {
}, [appId]);
const prefixCls = 'oak';
const prefixCls2 = `${prefixCls}-loginGrant`;
const { pathname, search } = window.location;
let V;
if (dev) {
V = (<div className={`${prefixCls2}_dev`}>
@ -38,7 +39,7 @@ function Grant(props) {
const url = new URL(decodeURIComponent(redirectUri));
url.searchParams.set('code', code);
if (state) {
url.searchParams.set('state', state || window.location.pathname);
url.searchParams.set('state', state || pathname + search);
}
window.location.href = url.toString();
setTimeout(() => {
@ -69,7 +70,7 @@ function Grant(props) {
return;
}
setDisabled2(true);
const url = WeChatLoginUrl(redirectUri, appId, scope, `&state=${state || window.location.pathname}`);
const url = WeChatLoginUrl(redirectUri, appId, scope, `&state=${state || pathname + search}`);
window.location.href = url;
setTimeout(() => {
setDisabled2(false);

View File

@ -53,6 +53,7 @@ function Grant(props: GrantProps) {
const prefixCls = 'oak';
const prefixCls2 = `${prefixCls}-loginGrant`;
const { pathname, search } = window.location;
let V;
if (dev) {
V = (
@ -86,7 +87,7 @@ function Grant(props: GrantProps) {
);
url.searchParams.set('code', code);
if (state) {
url.searchParams.set('state', state || window.location.pathname);
url.searchParams.set('state', state || pathname + search );
}
window.location.href = url.toString();
@ -130,7 +131,7 @@ function Grant(props: GrantProps) {
redirectUri,
appId,
scope,
`&state=${state || window.location.pathname}`,
`&state=${state || pathname + search}`,
);
window.location.href = url;