fix(auth): a tab acts only as the account it was built for, and the review's other findings
A tab names the account it was claimed for on every request, beacon and upload (X-Siftlode-Expect-Account); current_user and /auth/logout refuse a mismatch with 401 account_changed and keep the session, so a tab left showing the account signed in before reloads instead of writing to the new one. /auth/login clears a connect marker left by an abandoned connect, and a link completes only on a session that still holds. The prefs merge reads the row under a lock. A tab's sessionStorage records its own owner. A page the account loses is given up, address bar and remembered page included. The panel layouts are preferences; the storage contract also refuses a key handed to the Storage API or to usePref outside its kind. A refused sign-in as someone else and a failed sign-out say so. The chromium-only e2e specs are in the gate register, the member walk waits for its requests, and devices.spec checks the save itself.
This commit is contained in:
@@ -33,7 +33,7 @@ describe("claiming the browser's local data", () => {
|
||||
expect(keys(localStorage)).toEqual(
|
||||
["siftlode.filters", "siftlode.onboarding.dismissed", "siftlode.owner"].sort(),
|
||||
);
|
||||
expect(keys(sessionStorage)).toEqual(["siftlode.settingsTab"]);
|
||||
expect(keys(sessionStorage)).toEqual(["siftlode.owner", "siftlode.settingsTab"]);
|
||||
});
|
||||
|
||||
it("an old per-account copy wins over a plain key already there", async () => {
|
||||
@@ -82,7 +82,23 @@ describe("claiming the browser's local data", () => {
|
||||
["siftlode.owner", "siftlode.watchRepeat", "siftlode.watchResume", "unrelated.key"].sort(),
|
||||
);
|
||||
expect(localStorage.getItem("siftlode.owner")).toBe("1");
|
||||
expect(keys(sessionStorage)).toEqual([]);
|
||||
expect(keys(sessionStorage)).toEqual(["siftlode.owner"]);
|
||||
});
|
||||
|
||||
it("a tab reloading for the account another tab claimed the browser for drops its own view state", async () => {
|
||||
// Tab 2 signed in as 7 and claimed the browser; this tab still holds 1's sub-tab and the
|
||||
// onboarding flow 1 was in. Its sessionStorage is its own, so the browser's owner says nothing
|
||||
// about it.
|
||||
localStorage.setItem("siftlode.owner", "7");
|
||||
sessionStorage.setItem("siftlode.owner", "1");
|
||||
sessionStorage.setItem("siftlode.settingsTab", "plex");
|
||||
sessionStorage.setItem("siftlode.onboarding.active", "1");
|
||||
const { claimLocalData } = await storage();
|
||||
|
||||
claimLocalData(7);
|
||||
|
||||
expect(keys(sessionStorage)).toEqual(["siftlode.owner"]);
|
||||
expect(sessionStorage.getItem("siftlode.owner")).toBe("7");
|
||||
});
|
||||
|
||||
it("the same account starting again keeps everything", async () => {
|
||||
|
||||
Reference in New Issue
Block a user