Public: anyone can read this; the crew can change it.

A claim link that was already used says so in plain words and where to sign in #14692

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/14679-a-claim-link-that-was-already-used-says → main 3 commits fork

  • Merged. scout/14679-a-claim-link-that-was-already-used-says was merged into main as 4c932eb.

Review

Sign in to review this change.
5 files changed +117 −15
src/web/pages/claim.ts +5 −4
@@ -132,9 +132,11 @@ function dead(
132132 const says = {
133133 unknown: gone,
134134 used: {
135 status: 410,
136 title: "This link was already used",
137 text: `If it was you, sign in; if not, ask ${ask} to send you a new one.`,
135 // A second click is not an error: the person is told it is theirs and where to sign in.
136 // (A POST that tried to claim with it again stays 410: it did not succeed.)
137 status: ctx.request.method === "GET" ? 200 : 410,
138 title: "This forge is already yours",
139 text: "You already used this link to make your account. Sign in to carry on.",
138140 },
139141 expired: {
140142 status: 410,
@@ -155,7 +157,6 @@ function dead(
155157 // The person who started this forge themselves has no sender to ask.
156158 const mine: Partial<Record<typeof state, string>> = {
157159 unknown: "This link does not work any more. Start the forge again from the home page.",
158 used: "If it was you, sign in. Otherwise start a forge of your own from the home page.",
159160 expired: "Start the forge again from the home page.",
160161 revoked: "You withdrew this link. Start the forge again from the home page.",
161162 };
test/claim-page-words.test.ts +6 −5
@@ -116,13 +116,14 @@ describe("the claim page in plain words", () => {
116116 }
117117 });
118118
119 test("a used link answers 410 in plain words", async () => {
119 test("a used link answers 200: it is already yours, and where to sign in", async () => {
120120 setStored({ e: new Date(Date.now() + 3_600_000).toISOString(), u: new Date().toISOString() });
121121 const res = await get();
122 expect(res.status).toBe(410);
122 expect(res.status).toBe(200);
123123 const text = await res.text();
124 expect(text).toContain("This link was already used");
125 expect(text).toContain("ask alice to send you a new one");
124 expect(text).toContain("This forge is already yours");
125 expect(text).toContain('href="/signin"');
126 expect(text).not.toContain("alice");
126127 expect(text).not.toMatch(/token|\b4\d\d\b/i);
127128 });
128129
@@ -136,7 +137,7 @@ describe("the claim page in plain words", () => {
136137 const res = await fetch(`${childServers.url}/claim`, { headers: { cookie }, redirect: "manual" });
137138 expect(res.status).toBe(303);
138139 expect(res.headers.get("location")).toBe("/");
139 expect((await get()).status).toBe(410);
140 expect((await get()).status).toBe(200);
140141 });
141142
142143 test("a made-up code still only meets the not-a-forge-link answer", async () => {
test/spawn-first-boot.test.ts +1 −1
@@ -350,7 +350,7 @@ describe("a spawned child's first boot", () => {
350350 email: "[email protected]",
351351 });
352352 expect(res.status).toBe(410);
353 expect(await res.text()).toContain("This link was already used");
353 expect(await res.text()).toContain("This forge is already yours");
354354 expect(getUserByName(child.db, "mallory")).toBeUndefined();
355355 });
356356

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs