mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 13:20:19 +08:00
feat: support popup
mode in OAuth (#1668)
* feat: support `popup` mode in OAuth * feat: sendMessage when popup window closed * fix: fix param name error
This commit is contained in:
@ -204,6 +204,13 @@ class LoginPage extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendPopupData(message, redirectUri) {
|
||||||
|
const params = new URLSearchParams(this.props.location.search);
|
||||||
|
if (params.get("popup") === "1") {
|
||||||
|
window.opener.postMessage(message, redirectUri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
postCodeLoginAction(res) {
|
postCodeLoginAction(res) {
|
||||||
const application = this.getApplicationObj();
|
const application = this.getApplicationObj();
|
||||||
const ths = this;
|
const ths = this;
|
||||||
@ -243,6 +250,7 @@ class LoginPage extends React.Component {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Setting.goToLink(`${oAuthParams.redirectUri}${concatChar}code=${code}&state=${oAuthParams.state}`);
|
Setting.goToLink(`${oAuthParams.redirectUri}${concatChar}code=${code}&state=${oAuthParams.state}`);
|
||||||
|
this.sendPopupData({type: "loginSuccess", data: {code: code, state: oAuthParams.state}}, oAuthParams.redirectUri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -640,6 +648,12 @@ class LoginPage extends React.Component {
|
|||||||
this.onFinish(values);
|
this.onFinish(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (params.get("popup") === "1") {
|
||||||
|
window.addEventListener("beforeunload", () => {
|
||||||
|
this.sendPopupData({type: "windowClosed"}, params.get("redirect_uri"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (application.enableAutoSignin) {
|
if (application.enableAutoSignin) {
|
||||||
const values = {};
|
const values = {};
|
||||||
values["application"] = application.name;
|
values["application"] = application.name;
|
||||||
|
Reference in New Issue
Block a user