Skip to content

Commit 62e2d07

Browse files
fix(console): signing out no longer hands your list's filter, search and sort to the next person who signs in (#29305)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbYDsRkn71tNER7aYHM8b1BP)_ Fixes #29174 Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:会话结束时(点「退出登录」或会话过期),Console 跳到登录页所带的回跳链接 `?redirect=` 只保留列表的路径和其它参数(如 `recordId`),去掉列表的 `uf_*` 状态(筛选、搜索、排序、分组、快速筛选、标签页)。下一个在同一浏览器登录的人回到同一个列表,看到的是自己保存的状态或视图默认值,首个数据请求不再带上一个人的条件。 - **为什么改**:共享电脑上 A 退出、B 登录,B 会打开 A 的筛选、搜索和排序,而筛选值可能是敏感信息(客户名、金额、搜索词)。这是 18.3.0 RC 中 P1 条目 `records-forms.adhoc-filter-sort-builder` 的 A3、N2 失败项。 - **风险与回滚**:低。只改回跳链接的拼装,两个登录页都没动;没有列表状态时回跳链接逐字节不变;邀请链接不受影响。代价:同一用户会话过期后重新登录,回到同一列表,筛选面板、排序、搜索从本人存储恢复,但快速筛选标签和工具栏分组回到视图默认;未登录者打开带列表状态的分享链接,登录后落在该列表,用自己的状态而不是链接里的。回滚即回退本 PR。 - **先看**:`ui/apps/console/src/components/ProtectedRoute.tsx`(`LoginRedirect`);`ui/packages/app-shell/src/views/userFilterUrlState.ts`(`withoutListStateParams`);新测试 `ui/apps/console/src/components/ProtectedRoute.signOutListState-29174.test.tsx`。 - **两分钟验证**:`pnpm --dir ui exec vitest run apps/console/src/components/ProtectedRoute.signOutListState-29174.test.tsx`,预期 4 个用例全部通过;第一个用例断言 A 退出后登录页地址不含 `uf_` 和 "pipeline",B 登录后落在 `/apps/demo/demo_task/view/in_progress?recordId=r1`。 - **需要你做的**:无,席位落地。 ## What changes **The sign-in page's return link leaves the list's state behind.** When a session ends, the Console's signed-out guard (`LoginRedirect` in `ui/apps/console/src/components/ProtectedRoute.tsx`) sends the visitor to `/login?redirect=…`, and the Console login page follows that link after any successful sign-in. The guard built the link from the whole path and query, so a list's `uf_*` state rode into whoever signed in next. It now composes the link from the path plus every param that is not in the `uf_` family. When the URL carried no list state, the link keeps the original query byte for byte, so existing deep links do not change. **One helper, in the module that owns the `uf_` family.** `withoutListStateParams(searchParams)` in `ui/packages/app-shell/src/views/userFilterUrlState.ts` returns a copy without any `uf_*` param (the four toolbar keys, quick-filter `uf_<field>` and `uf__tab`), keeping every other param in order. It reuses the module's own prefix, so no second copy of the naming exists. It is exported from `@object-ui/app-shell`, which is `"private": true`, so no published surface widens (`Clause-②: no` as claimed). **Where the list then opens.** With no `uf_*` state in the URL, the list seeds from the signing-in user's own stored state (`objectViewListUrlState.ts`, seed leg 2: their Filter panel conditions and sort from their preferences, their search term from their per-user cache), or the view's default. B's storage is keyed by B's id, so nothing of A's is read. No server change, no metadata key or option, and neither login page is edited (so nothing overlaps #29136 or #29105). Rows were always read under the signing-in user's permissions; this is a state carry-over fix, not an access fix. ## Tests - `ui/apps/console/src/components/ProtectedRoute.signOutListState-29174.test.tsx` (new), 4 cases, through the real `AuthProvider` over a scripted auth client, the real `ProtectedRoute` (`AuthGuard` + `LoginRedirect`) and the real Console `LoginPage`: 1. the card's path: A is on a list URL carrying `uf__filter`, `uf__search`, `uf__sort`, `uf__group`, `uf_priority`, `uf__tab` and `recordId`; A signs out; the login page's URL carries no `uf_` param and none of A's values; B signs in on the form and lands on the list path with `recordId=r1` kept; 2. an invitation redirect (`/login?redirect=/accept-invitation/inv_1`) still lands on the invitation; 3. a signed-out arrival on a deep link with no list state keeps it byte for byte (`note=a%20b` stays `%20`); 4. a signed-out arrival on a link carrying list state loses it too (the guard cannot tell who signs in). - `ui/packages/app-shell/src/views/ObjectView.listUrlState-11860.test.tsx`: one new describe, 3 cases, at the data source of the real `ObjectView` and `ListView`: A's URL as A left it puts A's filter, search and sort into the first data request (control); the handed-over URL puts none of it there and the view's declared sort applies; the next user's own stored state applies there with nothing of A's merged in. - `ui/packages/app-shell/src/views/userFilterUrlState.withoutListState-29174.test.ts` (new), 6 cases: the whole `uf_` family goes, every other param stays in order, an empty-valued `uf_` param goes, the input is untouched, and params without list state come back equal. ## Acceptance notes - **Which site, measured on `origin/main` `692e0dc8`.** The card offered the sign-out side or the login side. The only composer of a list URL into `/login` is the Console's `LoginRedirect`; app-shell's `AuthenticatedRoute` sends a bare `/login`, and app-shell's `DefaultLoginPage` never follows `?redirect=` (it navigates to `/`). The follower is the Console `LoginPage` (`window.location.assign`). The guard was chosen because it is the single producer and needs no record of who left. A login-side drop would have needed that record to tell users apart, would still show A's values (the search term "pipeline") in the login page's address bar and history, and would have three followers to patch (login, register, verify-email-prompt), which all forward `?redirect=`. - **Same-user session expiry.** At the guard, an explicit sign-out and an expired or revoked session look the same (the auth context only says the user is gone), and telling them apart would need new state in `@object-ui/auth`. So both drop the list state, and the user's own return path (the list's path and other params) is kept. Measured in the real browser below: a user who typed a search, signed out and signed back in got their own search back from their per-user storage. Quick-filter chips and a toolbar grouping are not in per-user storage, so they fall back to the view's. - **A signed-out visitor opening a shared list link** now lands on that list after signing in, on their own state rather than the link's (test case 4). A visitor already signed in still opens the link's state exactly as before. - **Kept as non-list-state params:** `recordId`, `tab`, a related list's `filter[FIELD]` scoping, and any other param outside the `uf_` family. A `/login?redirect=…` URL composed elsewhere (bookmarked or typed) is still followed as written; the login pages are unchanged. - `content/docs/ui/views.mdx` gains one bullet under "A user's list state never writes the view". ## Verification All readings below are at head `a1fa3999` (this branch merged with `origin/main` `74a19dd8`) unless a line names another head. <details> <summary>Tests: 19 files, 194 passed</summary> `pnpm --dir ui exec vitest run` on the three test files above plus the 16 nearest suites (the Console's `App` route tests, `RootLandingRedirect`, `SetupRoute`, `StudioRoute` ×3, `FormPage.predicateScope`, `AcceptInvitationRoute`, `i18nAfterSignIn-12034`, `internalFormShell`, `ObjectView.ufViewSwitch-11992`, `userFilterUrlState.listState-11860` and the app-shell product-neutral ratchet): 19 files, 194 passed, 0 failed. The same set read 194/194 at `97150043` (before either merge) and at `13da5477` (after the first). </details> <details> <summary>Ablations: both go red, both restored to HEAD</summary> Run with `node scripts/ablation-replace.mjs`, which restores the file and checks its blob against HEAD. 1. Restore the verbatim redirect in `LoginRedirect` (`const redirect = location.pathname + returnSearch;` becomes `location.pathname + location.search`): the Console test file reads 2 failed, 2 passed. Red: "A signs out of a filtered, searched, sorted list; B signs in and lands on the path with none of it" and "a signed-out arrival on a link carrying list state loses the list state". Green, as they should be: the invitation redirect and the deep link with no list state. Restored blob `30df279f` == HEAD. 2. Make the helper keep every param (`if (!key.startsWith(PREFIX)) kept.append(…)` becomes an unconditional append): 7 failed, 34 passed across the three test files (the two Console cases above, three helper cases, and the two ObjectView cases that read the handed-over URL). Restored blob `44703363` == HEAD. </details> <details> <summary>Real browser: the card's path on a stock showcase boot</summary> Playwright (Chromium) against a fresh `showcase` boot built from this branch at `97150043`, through the real Console sign-in form. A is the seeded admin. B is a second member, invited, signed up and accepted on the same server. Both used the same browser context, as on a shared computer. - A opened `/apps/com.example.showcase/showcase_task/view/in_progress` with `uf__filter` (estimate_hours > 10 and progress < 80), `uf__search=pipeline` and `uf__sort` (due_date desc). A's first data request carried `search=pipeline`, `sort=-due_date` and both conditions. - A signed out from the Account menu. The login page's URL was `/_console/login?redirect=%2Fapps%2Fcom.example.showcase%2Fshowcase_task%2Fview%2Fin_progress`, with no `uf_` and no "pipeline". - B signed in on that page and landed on `/_console/apps/com.example.showcase/showcase_task/view/in_progress` with no `uf_`. B's first data request carried only the view's own filter (`status = in_progress`), with no search, no sort and none of A's conditions. - Control: B signing in on a `/login?redirect=` that holds A's state verbatim (what the guard composed before this change) lands with `uf_` in the URL, and B's first data request carries A's search, sort and both conditions. - Same user: A typed a search in the toolbar, signed out and signed back in. A's own search came back from A's per-user storage (the URL re-mirrored `uf__search=pipeline` and the first request carried `search=pipeline`). In the same browser, B signing in after A got the view's default. </details> <details> <summary>Type-check, lint, build</summary> - `pnpm --filter @object-ui/app-shell run type-check` and `pnpm --filter @object-ui/console run type-check` under `ui/`: exit 0. - eslint on the six touched source and test files: 0 errors; 8 warnings, all pre-existing `no-explicit-any` lines in `ObjectView.listUrlState-11860.test.tsx` outside this change. - `pnpm exec turbo run build --filter=!@objectstack/docs`: 117 of 117 tasks. - `pnpm check:new-line-citations` under `ui/`: 0 new citations. </details> <details> <summary>Derived gates: 66 derived, 66 run, all exit 0</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derives 66 commands for this change set, the same 66 at `13da5477` and at `a1fa3999`. All 66 ran at both heads with exit 0, each code recorded, including `pnpm --dir ui exec vitest run scripts/` (169 files passed, 2 skipped; 4900 tests passed). `dispatch-gates --ran` reconciles: 66 derived, 66 run, 0 NOT-MEASURED, 0 UNRUN. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QsR2jTDksad4P3chz5nFKY --- _Generated by [Claude Code](https://claude.ai/code/session_01QsR2jTDksad4P3chz5nFKY)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 08610a9 commit 62e2d07

8 files changed

Lines changed: 420 additions & 2 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/console': patch
4+
---
5+
6+
fix(console): signing out no longer hands your list's filter, search and sort to the next person who signs in
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
A list keeps its toolbar state in the URL (`uf__filter`, `uf__search`, `uf__sort`, `uf__group`, quick-filter `uf_<field>` and `uf__tab`). When a session ended, the Console sent the visitor to the sign-in page with a return link built from that whole URL, and the sign-in page follows the link after any successful sign-in. On a shared desk or kiosk browser, the next person to sign in therefore opened the previous user's filtered, searched and sorted list, and their first data request carried it.
12+
13+
The return link now keeps the list's path and every other parameter (a record open beside the list, a tab, a deep link's own query), and drops the `uf_*` list state. The list then opens on the signing-in user's own stored state, or on the view's default. Rows were always read under the signing-in user's own permissions; what changes is that none of the previous user's filter values reach the next user's list, their first data request, or the sign-in page's address bar.
14+
15+
The Console cannot tell an explicit sign-out from an expired session at that point, so both behave the same way. Someone whose session expired and who signs back in returns to the same list with their own saved filter, search and sort; quick-filter chips and a toolbar grouping fall back to the view's. A signed-out visitor who opens a shared link carrying list state lands on that list after signing in, on their own state rather than the link's. An invitation link (`?redirect=/accept-invitation/ID`) is unchanged.

‎content/docs/ui/views.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ metadata is read-only. What you author (`sort`, filters, columns, `rowHeight`,
550550
`hiddenFields`, the views' order) is the default for every user with no state of their own.
551551

552552
- A link carrying list state (`uf_*` parameters) wins over the stored state.
553+
- When a session ends, the sign-in page's return link keeps the list's path but never its
554+
`uf_*` state, so whoever signs in next opens their own stored state or the view's default.
553555
- A user's hidden fields only subtract from the columns the view shows, never add one.
554556
- While a user's list differs from the view, a **Personalized** marker sits beside the list
555557
title (an icon alone on a phone). Opening it names what differs: filters, search, sort,
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#29174 — signing out leaves the list's state behind.
5+
*
6+
* A list mirrors its toolbar state into the URL (`uf__filter`, `uf__search`,
7+
* `uf__sort`, `uf__group`, a quick filter's `uf_<field>`, the tab preset's
8+
* `uf__tab`; `views/userFilterUrlState.ts` in app-shell owns the family). When
9+
* the session ends, `LoginRedirect` sends the visitor to `/login` with a
10+
* `?redirect=` return link, and the login page follows that link after ANY
11+
* successful sign-in. So whoever signs in next on that browser used to open
12+
* the previous user's filtered, searched and sorted list — on a shared desk or
13+
* kiosk, the next person.
14+
*
15+
* Pinned here, through the REAL composition: the real `AuthProvider` over a
16+
* scripted auth client (the session is A's until A signs out, then B's once B
17+
* signs in on the form), the real `ProtectedRoute` (its `AuthGuard` and
18+
* `LoginRedirect`), and the real Console `LoginPage` with its post-login
19+
* hand-off. Only the shell's provider stack is a pass-through.
20+
*
21+
* - A signs out of a list carrying every kind of list state; the login page's
22+
* URL carries none of it, and B lands on the same path with the other
23+
* params kept (the card's reproduction, steps 4 to 7);
24+
* - an invitation redirect still lands on the invitation;
25+
* - a signed-out arrival on a deep link with no list state keeps it byte for
26+
* byte;
27+
* - a signed-out arrival on a link WITH list state loses that state too: the
28+
* guard cannot tell who will sign in, so it never forwards it.
29+
*
30+
* What B's list then opens with at that landing URL — B's own stored state or
31+
* the view's default, and nothing of A's in the first data request — is pinned
32+
* in app-shell's `ObjectView.listUrlState-11860.test.tsx`.
33+
*/
34+
35+
import '@testing-library/jest-dom/vitest';
36+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
37+
import { render, screen, waitFor, cleanup } from '@testing-library/react';
38+
import userEvent from '@testing-library/user-event';
39+
import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom';
40+
import type { ReactNode } from 'react';
41+
import { AuthProvider, useAuth } from '@object-ui/auth';
42+
import type { AuthClient } from '@object-ui/auth';
43+
44+
vi.mock('@object-ui/app-shell', async (importOriginal) => ({
45+
...(await importOriginal<Record<string, unknown>>()),
46+
// Pass-through: the shell's provider stack does not decide where the guard
47+
// sends a signed-out visitor.
48+
ConnectedShell: ({ children }: { children?: ReactNode }) => <>{children}</>,
49+
RequireOrganization: ({ children }: { children?: ReactNode }) => <>{children}</>,
50+
LoadingFallback: () => <div data-testid="loading" />,
51+
}));
52+
53+
import { ProtectedRoute } from './ProtectedRoute';
54+
import { LoginPage } from '../pages/auth/LoginPage';
55+
import { withConsoleBase } from '../utils/consoleBase';
56+
57+
const LIST_PATH = '/apps/demo/demo_task/view/in_progress';
58+
59+
/** A's list, as the list writes it: two Filter panel conditions, a search, a sort, a grouping, a chip, a tab, and a record open beside it. */
60+
const A_LIST_SEARCH = new URLSearchParams([
61+
[
62+
'uf__filter',
63+
JSON.stringify({
64+
logic: 'and',
65+
conditions: [
66+
{ field: 'estimate_hours', operator: 'greater_than', value: 10 },
67+
{ field: 'progress', operator: 'less_than', value: 80 },
68+
],
69+
}),
70+
],
71+
['uf__search', 'pipeline'],
72+
['uf__sort', JSON.stringify([{ field: 'due_date', order: 'desc' }])],
73+
['uf__group', JSON.stringify({ fields: [{ field: 'status', order: 'asc', collapsed: false }] })],
74+
['uf_priority', 'urgent'],
75+
['uf__tab', 'mine'],
76+
['recordId', 'r1'],
77+
]).toString();
78+
79+
const A_LIST_URL = `${LIST_PATH}?${A_LIST_SEARCH}`;
80+
81+
const USER_A = { id: 'user_a', name: 'Ada', email: 'ada@example.com' };
82+
const USER_B = { id: 'user_b', name: 'Ben', email: 'ben@example.com' };
83+
84+
/** The session the scripted server holds, newest state wins. */
85+
let serverUser: typeof USER_A | null;
86+
87+
function createClient(): AuthClient {
88+
return {
89+
getSession: vi.fn(async () => (serverUser ? { user: serverUser, session: { token: `tok_${serverUser.id}` } } : null)),
90+
getConfig: vi.fn().mockResolvedValue({ emailPassword: { enabled: true, disableSignUp: true } }),
91+
signOut: vi.fn(async () => {
92+
serverUser = null;
93+
}),
94+
signIn: vi.fn(async ({ email }: { email: string }) => {
95+
serverUser = email === USER_B.email ? USER_B : USER_A;
96+
return { user: serverUser, session: { token: `tok_${serverUser.id}` } };
97+
}),
98+
} as unknown as AuthClient;
99+
}
100+
101+
/** Every location the router settles on, oldest first. */
102+
const seen: string[] = [];
103+
function LocationProbe() {
104+
const location = useLocation();
105+
seen.push(location.pathname + location.search);
106+
return null;
107+
}
108+
109+
/** The list page, reduced to the account menu's sign-out. */
110+
function SignedInList() {
111+
const { user, signOut } = useAuth();
112+
return (
113+
<div data-testid="list-page" data-user={user?.id ?? ''}>
114+
<button type="button" onClick={() => void signOut()}>
115+
Sign out
116+
</button>
117+
</div>
118+
);
119+
}
120+
121+
function renderConsole(entry: string, client: AuthClient) {
122+
return render(
123+
<AuthProvider authUrl="/api/v1/auth" client={client}>
124+
<MemoryRouter initialEntries={[entry]}>
125+
<LocationProbe />
126+
<Routes>
127+
<Route path="/login" element={<LoginPage />} />
128+
<Route
129+
path="/apps/*"
130+
element={
131+
<ProtectedRoute requireOrganization={false}>
132+
<SignedInList />
133+
</ProtectedRoute>
134+
}
135+
/>
136+
</Routes>
137+
</MemoryRouter>
138+
</AuthProvider>,
139+
);
140+
}
141+
142+
/** The login page the router settled on, and its `?redirect=` decoded. */
143+
async function loginRedirect(): Promise<{ url: string; redirect: string | null }> {
144+
await screen.findByLabelText('Email');
145+
const url = seen[seen.length - 1]!;
146+
expect(url.startsWith('/login')).toBe(true);
147+
return { url, redirect: new URLSearchParams(url.slice('/login'.length)).get('redirect') };
148+
}
149+
150+
async function signInAs(email: string) {
151+
const user = userEvent.setup();
152+
await user.type(await screen.findByLabelText('Email'), email);
153+
await user.type(screen.getByLabelText('Password'), 'pw-29174');
154+
await user.click(screen.getByRole('button', { name: 'Sign In' }));
155+
}
156+
157+
/** The URL the login page sends the browser to once someone is signed in. */
158+
async function landing(): Promise<string> {
159+
const assign = vi.mocked(window.location.assign);
160+
await waitFor(() => expect(assign).toHaveBeenCalled());
161+
expect(assign).toHaveBeenCalledTimes(1);
162+
return String(assign.mock.calls[0]![0]);
163+
}
164+
165+
beforeEach(() => {
166+
seen.length = 0;
167+
serverUser = null;
168+
window.localStorage.clear();
169+
window.sessionStorage.clear();
170+
vi.spyOn(window.location, 'assign').mockImplementation(() => undefined);
171+
});
172+
173+
afterEach(() => {
174+
cleanup();
175+
vi.restoreAllMocks();
176+
});
177+
178+
describe('signing out leaves the list state behind (objectstack#29174)', () => {
179+
it('A signs out of a filtered, searched, sorted list; B signs in and lands on the path with none of it', async () => {
180+
serverUser = USER_A;
181+
const client = createClient();
182+
renderConsole(A_LIST_URL, client);
183+
184+
// A is on the list, and the URL carries A's list state (the control).
185+
expect((await screen.findByTestId('list-page')).dataset.user).toBe(USER_A.id);
186+
expect(seen[seen.length - 1]).toBe(A_LIST_URL);
187+
188+
await userEvent.setup().click(screen.getByRole('button', { name: 'Sign out' }));
189+
expect(client.signOut).toHaveBeenCalledTimes(1);
190+
191+
// The login page's own URL carries none of it: not the params, not a value.
192+
const { url, redirect } = await loginRedirect();
193+
expect(redirect).toBe(`${LIST_PATH}?recordId=r1`);
194+
expect(decodeURIComponent(url)).not.toContain('uf_');
195+
expect(decodeURIComponent(url)).not.toContain('pipeline');
196+
expect(decodeURIComponent(url)).not.toContain('estimate_hours');
197+
198+
await signInAs(USER_B.email);
199+
expect(client.signIn).toHaveBeenLastCalledWith(
200+
expect.objectContaining({ email: USER_B.email }),
201+
);
202+
203+
// B lands on the list's path, with the record param kept.
204+
const landed = await landing();
205+
expect(landed).toBe(withConsoleBase(`${LIST_PATH}?recordId=r1`));
206+
expect(landed).not.toContain('uf_');
207+
});
208+
209+
it('an invitation redirect still lands on the invitation', async () => {
210+
const client = createClient();
211+
renderConsole(`/login?redirect=${encodeURIComponent('/accept-invitation/inv_1')}`, client);
212+
213+
await signInAs(USER_B.email);
214+
215+
expect(await landing()).toBe(withConsoleBase('/accept-invitation/inv_1'));
216+
});
217+
218+
it('a signed-out arrival on a deep link with no list state keeps it byte for byte', async () => {
219+
const deepLink = '/apps/demo/demo_task/record/r1?tab=details&note=a%20b';
220+
const client = createClient();
221+
renderConsole(deepLink, client);
222+
223+
const { url, redirect } = await loginRedirect();
224+
expect(url).toBe(`/login?redirect=${encodeURIComponent(deepLink)}`);
225+
expect(redirect).toBe(deepLink);
226+
227+
await signInAs(USER_B.email);
228+
expect(await landing()).toBe(withConsoleBase(deepLink));
229+
});
230+
231+
it('a signed-out arrival on a link carrying list state loses the list state: the guard cannot tell who signs in', async () => {
232+
const client = createClient();
233+
renderConsole(A_LIST_URL, client);
234+
235+
const { redirect } = await loginRedirect();
236+
expect(redirect).toBe(`${LIST_PATH}?recordId=r1`);
237+
});
238+
});

‎ui/apps/console/src/components/ProtectedRoute.tsx‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
RequireOrganization,
1919
LoadingFallback,
2020
RedirectWithSplash,
21+
withoutListStateParams,
2122
} from '@object-ui/app-shell';
2223

2324
/**
@@ -27,10 +28,20 @@ import {
2728
* `window.location` — the Console is mounted under a `<base href>` basename in
2829
* every embedded deployment, so a window-derived path would carry the `/_console`
2930
* mount into a value that `LoginPage` then re-prefixes with it (objectui#4168).
31+
*
32+
* It never carries the list's `uf_*` state (objectstack#29174). Whoever signs in
33+
* on that page may not be the person whose session just ended, and a filter
34+
* value can be sensitive; this guard cannot tell a sign-out from an expiry, so
35+
* it drops the state for both. The path and every other param are kept, byte
36+
* for byte when there was no list state, and the list then opens on the
37+
* signing-in user's own stored state or the view's default.
3038
*/
3139
export function LoginRedirect() {
3240
const location = useLocation();
33-
const redirect = location.pathname + location.search;
41+
const params = new URLSearchParams(location.search);
42+
const kept = withoutListStateParams(params).toString();
43+
const returnSearch = kept === params.toString() ? location.search : kept ? `?${kept}` : '';
44+
const redirect = location.pathname + returnSearch;
3445
const search = redirect && redirect !== '/' ? `?redirect=${encodeURIComponent(redirect)}` : '';
3546
// `RedirectWithSplash`, not a bare `<Navigate>` (objectui#6378): this element
3647
// replaces the `LoadingFallback` the SAME `AuthGuard` was rendering one state

‎ui/packages/app-shell/src/index.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ export type {
225225
ScreenSpec,
226226
ScreenFieldSpec,
227227
} from './views/index.js';
228+
// The list's URL state stays behind when the session ends: the Console's
229+
// signed-out guard composes the sign-in page's return link without it.
230+
export { withoutListStateParams } from './views/userFilterUrlState.js';
228231

229232
// Hooks
230233
export {

‎ui/packages/app-shell/src/views/ObjectView.listUrlState-11860.test.tsx‎

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ import { ObjectView } from './ObjectView';
9595
import '@object-ui/plugin-grid';
9696
import { ExpressionProvider } from '../providers/ExpressionProvider';
9797
import { buildListFilterKey } from './listFilterStorage';
98-
import { LIST_FILTER_PARAM, LIST_GROUP_PARAM, LIST_SEARCH_PARAM, LIST_SORT_PARAM } from './userFilterUrlState';
98+
import { LIST_FILTER_PARAM, LIST_GROUP_PARAM, LIST_SEARCH_PARAM, LIST_SORT_PARAM, withoutListStateParams } from './userFilterUrlState';
9999
import { localListStateKey } from '../context/ListPreferencesProvider';
100100
import { acceptStoredFilters, acceptStoredSort } from './objectViewListUrlState';
101101

@@ -701,3 +701,46 @@ describe('a link\'s sort wins over the sort its view declares (objectui#11860)',
701701
expect(new URLSearchParams(host.search()).has(LIST_SORT_PARAM)).toBe(false);
702702
});
703703
});
704+
705+
describe('the link a sign-in hands over opens the next user\'s list on their own state (objectstack#29174)', () => {
706+
/** A's list, as A left it when the session ended: a filter, a search and a sort on a view that declares its own sort. */
707+
const A_LEFT = link(`${VIEW}/sorted`, { filter: URGENT, search: 'pipeline', sort: [{ field: 'due_date', order: 'desc' }] });
708+
/** The return link the Console's signed-out guard composes from it (`LoginRedirect` in `apps/console`). */
709+
const handedOver = () => {
710+
const [path, query] = A_LEFT.split('?');
711+
const kept = withoutListStateParams(new URLSearchParams(query)).toString();
712+
return kept ? `${path}?${kept}` : path!;
713+
};
714+
const firstQuery = () => listQueries[0];
715+
716+
it('CONTROL: A\'s URL as A left it puts A\'s state into the first data request', async () => {
717+
await mountHost([A_LEFT]);
718+
const first = firstQuery();
719+
expect(filterOf(first)).toContain('"priority","=","urgent"');
720+
expect(first.$search).toBe('pipeline');
721+
expect(first.$orderby).toEqual([{ field: 'due_date', order: 'desc' }]);
722+
});
723+
724+
it('at the handed-over URL, the next user\'s first data request carries none of it: the view\'s default', async () => {
725+
const host = await mountHost([handedOver()]);
726+
const first = firstQuery();
727+
expect(filterOf(first)).not.toContain('urgent');
728+
expect(first.$search).toBeUndefined();
729+
expect(first.$orderby).toEqual([{ field: 'name', order: 'asc' }]);
730+
// Nor is any of it written back into the address bar.
731+
expect(host.search()).not.toContain('pipeline');
732+
expect(host.search()).not.toContain('urgent');
733+
});
734+
735+
it('the next user\'s own stored state applies there, and nothing of A\'s is merged in', async () => {
736+
storeListState('sorted', {
737+
filters: { id: 'root', logic: 'and', conditions: [{ id: 'r', field: 'status', operator: 'equals', value: 'open' }] },
738+
search: 'mine',
739+
});
740+
await mountHost([handedOver()]);
741+
const first = firstQuery();
742+
expect(filterOf(first)).toContain('"status","=","open"');
743+
expect(filterOf(first)).not.toContain('urgent');
744+
expect(first.$search).toBe('mine');
745+
});
746+
});

‎ui/packages/app-shell/src/views/userFilterUrlState.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,23 @@ export function userFilterParamsKey(searchParams: URLSearchParams): string {
131131
return own.toString();
132132
}
133133

134+
/**
135+
* A copy of the given params without the `uf_` family: every piece of list
136+
* state this module owns, quick filters and the tab preset included. Every
137+
* other param is kept, in its order.
138+
*
139+
* The Console's signed-out guard composes the sign-in page's return link with
140+
* it: list state belongs to the person who left, and a filter value can be
141+
* sensitive, so it never rides into whoever signs in next (objectstack#29174).
142+
*/
143+
export function withoutListStateParams(searchParams: URLSearchParams): URLSearchParams {
144+
const kept = new URLSearchParams();
145+
searchParams.forEach((value, key) => {
146+
if (!key.startsWith(PREFIX)) kept.append(key, value);
147+
});
148+
return kept;
149+
}
150+
134151
/** One sort entry, in the spec's `ListViewSchema.sort` element shape. */
135152
export interface ListSortRule {
136153
field: string;

0 commit comments

Comments
 (0)