ИСПРАВЛЕНИЕ - NODEDC AUTH: вернуть после logout-flow
This commit is contained in:
parent
b34461f64e
commit
81c7f434e6
|
|
@ -262,6 +262,66 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isOidcLogoutFlow() {
|
||||||
|
const path = window.location.pathname;
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
|
return (
|
||||||
|
path.includes("/end-session/") ||
|
||||||
|
path.includes("/if/flow/default-invalidation-flow") ||
|
||||||
|
params.has("post_logout_redirect_uri")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSafePostLogoutRedirect() {
|
||||||
|
const rawUrl = new URLSearchParams(window.location.search).get("post_logout_redirect_uri");
|
||||||
|
if (!rawUrl) return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const url = new URL(rawUrl);
|
||||||
|
const allowedHosts = new Set([
|
||||||
|
"launcher.local.nodedc",
|
||||||
|
"launcher.local.notdc",
|
||||||
|
"launcher.notdc.ru",
|
||||||
|
"platform.notdc.ru",
|
||||||
|
"notdc.ru",
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!["http:", "https:"].includes(url.protocol)) return null;
|
||||||
|
if (!allowedHosts.has(url.hostname)) return null;
|
||||||
|
if (!url.pathname.startsWith("/auth/logged-out")) return null;
|
||||||
|
|
||||||
|
return url.toString();
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function redirectCompletedLogout(root) {
|
||||||
|
if (!isOidcLogoutFlow() || document.body?.dataset.nodedcLogoutRedirected === "true") return;
|
||||||
|
|
||||||
|
const redirectUrl = getSafePostLogoutRedirect();
|
||||||
|
if (!redirectUrl) return;
|
||||||
|
|
||||||
|
const text = root.textContent || "";
|
||||||
|
const logoutComplete = [
|
||||||
|
"Logout successful",
|
||||||
|
"You've logged out",
|
||||||
|
"You have been logged out",
|
||||||
|
"Logged out",
|
||||||
|
"Вы вышли",
|
||||||
|
"Выход выполнен",
|
||||||
|
].some((message) => text.includes(message));
|
||||||
|
|
||||||
|
if (!logoutComplete) return;
|
||||||
|
|
||||||
|
document.body.dataset.nodedcLogoutRedirected = "true";
|
||||||
|
document.body.classList.add("nodedc-auth-submitting");
|
||||||
|
window.setTimeout(() => {
|
||||||
|
window.location.replace(redirectUrl);
|
||||||
|
}, 150);
|
||||||
|
}
|
||||||
|
|
||||||
let scheduled = false;
|
let scheduled = false;
|
||||||
|
|
||||||
function enhanceAuthFields() {
|
function enhanceAuthFields() {
|
||||||
|
|
@ -273,6 +333,7 @@
|
||||||
enhanceSubmitHandoff(root);
|
enhanceSubmitHandoff(root);
|
||||||
translateAuthText(root);
|
translateAuthText(root);
|
||||||
restoreCardOnErrors(root);
|
restoreCardOnErrors(root);
|
||||||
|
redirectCompletedLogout(root);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue