mirror of
https://github.com/bitbaum/causius.git
synced 2026-12-03 22:07:34 +01:00
* feat(auth): account mail through AccountKit's shared mailer, with the sign-in code
The account mails stay this app's own words, in the reader's language, with
HTML: the template is handed to createAuthMailer({ render, codes: true })
(AccountKit 0.26.1). The shared mailer checks the link's origin, skips
addresses that cannot receive mail and puts a six-digit code in the sign-in
link's email, which the template prints ("On another device? Type this
code ..."). The sign-in page then offers the field for it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* chore: keep main's AccountKit 0.27.0 (the merge had lowered it)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
---------
Co-authored-by: Claude <noreply@anthropic.com>
22 lines
809 B
TypeScript
22 lines
809 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { authMail, renderAuthMail } from "./mail";
|
|
import { SITE } from "./site";
|
|
|
|
describe("the sign-in code in the sign-in link's email", () => {
|
|
const link = `${SITE.url}/api/auth/magic-link/verify?token=t&callbackURL=%2Fde%2Faccount`;
|
|
|
|
it("is printed in the reader's language, in the text and the HTML", () => {
|
|
const mail = renderAuthMail("magicLink", link, "de", "123456");
|
|
expect(mail.text).toContain("123 456");
|
|
expect(mail.html).toContain("123 456");
|
|
expect(mail.text).toContain("Gerät");
|
|
});
|
|
|
|
it("is left out when there is none, and the shared mailer says it prints one", () => {
|
|
expect(renderAuthMail("magicLink", link, "en").text).not.toMatch(
|
|
/\d{3} \d{3}/,
|
|
);
|
|
expect(authMail.codes).toBe(true);
|
|
});
|
|
});
|