mirror of https://github.com/casbin/casnode.git
Fix SilentSignin logic
This commit is contained in:
parent
62b058eb5e
commit
ef70126b37
|
@ -78,7 +78,7 @@ export function getMyResourcesUrl(account) {
|
|||
export function signin() {
|
||||
return CasdoorSdk.signin(ServerUrl).then((res) => {
|
||||
if (res.status === "ok") {
|
||||
if (window !== window.parent) {
|
||||
if (inIframe()) {
|
||||
const message = {tag: "Casdoor", type: "SilentSignin", data: "success"};
|
||||
window.parent.postMessage(message, "*");
|
||||
}
|
||||
|
@ -89,6 +89,14 @@ export function signin() {
|
|||
});
|
||||
}
|
||||
|
||||
export function inIframe() {
|
||||
try {
|
||||
return window !== window.parent;
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export function scrollToTop() {
|
||||
scroll.scrollToTop();
|
||||
}
|
||||
|
|
|
@ -33,17 +33,19 @@ class SilentSignin extends React.Component {
|
|||
return;
|
||||
}
|
||||
|
||||
if (message.type === "SilentSignin" && message.data === "success") {
|
||||
Setting.showMessageEx("success", i18next.t("login:Logged in successfully"), 1, () => Setting.goToLink("/"));
|
||||
} else if (message.type === "SilentSignin" && message.data === "user-not-logged-in") {
|
||||
Setting.showMessageEx("error", i18next.t("login:Failed to log in"), 1, () => Setting.goToLink("/"));
|
||||
if (message.type === "SilentSignin") {
|
||||
if (message.data === "success") {
|
||||
Setting.showMessageEx("success", i18next.t("login:Logged in successfully"), 1, () => Setting.goToLink("/"));
|
||||
} else if (message.data === "user-not-logged-in") {
|
||||
// Setting.showMessageEx("error", i18next.t("login:Failed to log in"), 1, () => Setting.goToLink("/"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
// don't silent-sign-in recursively in iframe
|
||||
if (window !== window.parent) {
|
||||
if (Setting.inIframe()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue