1
0
forked from baron/baron-sso

Show orgfront login page for regular entries

This commit is contained in:
2026-06-23 08:41:40 +09:00
parent 20811d8b99
commit 7d4fa631ae
2 changed files with 12 additions and 1 deletions

View File

@@ -36,6 +36,7 @@ function renderGuard(initialEntry: string) {
<MemoryRouter initialEntries={[initialEntry]}>
<Routes>
<Route element={<AuthGuard />}>
<Route path="/chart" element={<div>chart</div>} />
<Route path="/embed/picker" element={<div>picker</div>} />
</Route>
<Route path="/login" element={<LocationProbe />} />
@@ -74,4 +75,11 @@ describe("OrgFront AuthGuard auto login redirects", () => {
);
cleanupRendered(rendered.container, rendered.root);
});
it("redirects regular app entry to the visible login page", () => {
const rendered = renderGuard("/chart");
expect(rendered.container.textContent).toBe("/login?returnTo=%2Fchart");
cleanupRendered(rendered.container, rendered.root);
});
});

View File

@@ -29,9 +29,12 @@ export default function AuthGuard() {
if (!auth.isAuthenticated) {
const returnTo = `${location.pathname}${location.search}`;
const autoLoginParam = location.pathname.startsWith("/embed/")
? "auto=1&"
: "";
return (
<Navigate
to={`/login?auto=1&returnTo=${encodeURIComponent(returnTo)}`}
to={`/login?${autoLoginParam}returnTo=${encodeURIComponent(returnTo)}`}
replace
/>
);