feat(ui): allow direct logout redirects to safe return urls instead of forcing login page

This commit is contained in:
Tyler Gillispie 2026-08-24 16:22:15 -07:00
parent 8babb8a46e
commit 561588624a
2 changed files with 4 additions and 1 deletions

View File

@ -1129,6 +1129,7 @@ app.get("/api/forward-auth", async (c) => {
// If a browser is requesting a webpage on an unregistered domain, seamlessly redirect to unregistered error view // If a browser is requesting a webpage on an unregistered domain, seamlessly redirect to unregistered error view
if (accept.includes("text/html")) { if (accept.includes("text/html")) {
const loginDomain = rpID || "auth.atyg.org"; const loginDomain = rpID || "auth.atyg.org";
c.header("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
return c.redirect( return c.redirect(
`https://${loginDomain}/errors/unregistered?host=${ `https://${loginDomain}/errors/unregistered?host=${
encodeURIComponent(host) encodeURIComponent(host)
@ -1191,6 +1192,7 @@ app.get("/api/forward-auth", async (c) => {
// If a browser is requesting a webpage, seamlessly redirect to login // If a browser is requesting a webpage, seamlessly redirect to login
if (accept.includes("text/html")) { if (accept.includes("text/html")) {
const loginDomain = rpID || "auth.atyg.org"; const loginDomain = rpID || "auth.atyg.org";
c.header("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
return c.redirect( return c.redirect(
`https://${loginDomain}/login?redirect=${ `https://${loginDomain}/login?redirect=${
encodeURIComponent(originalUrl) encodeURIComponent(originalUrl)

View File

@ -98,7 +98,8 @@ uiApp.get("/logout", async (c) => {
}); });
if (safeRedirect) { if (safeRedirect) {
return c.redirect(`/login?redirect=${encodeURIComponent(safeRedirect)}`); c.header("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
return c.redirect(safeRedirect);
} }
c.header("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0"); c.header("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
return c.redirect("/login"); return c.redirect("/login");