Spend login, invite, and email-change links only after a confirm POST so mail scanners cannot use them up.

GET still shows a one-button page, a used invitation can resend or reopen for the signed-in invitee, and an email-change GET no longer signs the account out.
This commit is contained in:
adilallo committed 2026-11-22 16:58:30 -07:00
1 parent 600056499c
commit a725cf1a32
33 files changed
+1002 -89

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
import { describe, expect, it } from "vitest";
import {
emailChangeConfirmPath,
emailChangeVerifyPath,
inviteConfirmPath,
inviteVerifyPath,
magicLinkConfirmPath,
magicLinkVerifyPath,
} from "../../lib/create/confirmLinkPaths";
describe("confirmLinkPaths", () => {
it("encodes tokens on confirm and verify URLs", () => {
expect(magicLinkConfirmPath("a+b")).toBe("/login/confirm?token=a%2Bb");
expect(magicLinkVerifyPath("a+b")).toBe(
"/api/auth/magic-link/verify?token=a%2Bb",
);
expect(emailChangeConfirmPath("a+b")).toBe(
"/email-change/confirm?token=a%2Bb",
);
expect(emailChangeVerifyPath("a+b")).toBe(
"/api/user/email-change/verify?token=a%2Bb",
);
});
it("keeps copy=1 on invitation confirm and verify URLs", () => {
expect(inviteConfirmPath("abc1234567", { copy: true })).toBe(
"/invite/confirm?token=abc1234567&copy=1",
);
expect(inviteVerifyPath("abc1234567", { copy: true })).toBe(
"/api/invites/rule-stakeholder/verify?token=abc1234567&copy=1",
);
});
});