mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-05 05:50:19 +08:00
fix: add oauth login auto close page (#915)
This commit is contained in:
@ -207,6 +207,7 @@ class LoginPage extends React.Component {
|
|||||||
} else if (responseType === "code") {
|
} else if (responseType === "code") {
|
||||||
const code = res.data;
|
const code = res.data;
|
||||||
const concatChar = oAuthParams?.redirectUri?.includes("?") ? "&" : "?";
|
const concatChar = oAuthParams?.redirectUri?.includes("?") ? "&" : "?";
|
||||||
|
const noRedirect = oAuthParams.noRedirect;
|
||||||
|
|
||||||
if (Setting.hasPromptPage(application)) {
|
if (Setting.hasPromptPage(application)) {
|
||||||
AuthBackend.getAccount("")
|
AuthBackend.getAccount("")
|
||||||
@ -228,7 +229,19 @@ class LoginPage extends React.Component {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Setting.goToLink(`${oAuthParams.redirectUri}${concatChar}code=${code}&state=${oAuthParams.state}`);
|
if (noRedirect === "true") {
|
||||||
|
window.close();
|
||||||
|
const newWindow = window.open(`${oAuthParams.redirectUri}${concatChar}code=${code}&state=${oAuthParams.state}`);
|
||||||
|
if (newWindow) {
|
||||||
|
setInterval(() => {
|
||||||
|
if (!newWindow.closed) {
|
||||||
|
newWindow.close();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Setting.goToLink(`${oAuthParams.redirectUri}${concatChar}code=${code}&state=${oAuthParams.state}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Util.showMessage("success", `Authorization code: ${res.data}`);
|
// Util.showMessage("success", `Authorization code: ${res.data}`);
|
||||||
|
@ -103,6 +103,7 @@ export function getOAuthGetParameters(params) {
|
|||||||
const codeChallenge = getRefinedValue(queries.get("code_challenge"));
|
const codeChallenge = getRefinedValue(queries.get("code_challenge"));
|
||||||
const samlRequest = getRefinedValue(queries.get("SAMLRequest"));
|
const samlRequest = getRefinedValue(queries.get("SAMLRequest"));
|
||||||
const relayState = getRefinedValue(queries.get("RelayState"));
|
const relayState = getRefinedValue(queries.get("RelayState"));
|
||||||
|
const noRedirect = getRefinedValue(queries.get("noRedirect"));
|
||||||
|
|
||||||
if ((clientId === undefined || clientId === null || clientId === "") && (samlRequest === "" || samlRequest === undefined)) {
|
if ((clientId === undefined || clientId === null || clientId === "") && (samlRequest === "" || samlRequest === undefined)) {
|
||||||
// login
|
// login
|
||||||
@ -120,6 +121,7 @@ export function getOAuthGetParameters(params) {
|
|||||||
codeChallenge: codeChallenge,
|
codeChallenge: codeChallenge,
|
||||||
samlRequest: samlRequest,
|
samlRequest: samlRequest,
|
||||||
relayState: relayState,
|
relayState: relayState,
|
||||||
|
noRedirect: noRedirect,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user