Repository navigation
Commit d609f60
fix(plugin-auth): the Magic Link mail states the lifetime the link really has, five minutes (#25238)
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuACdPWFJTLDcTrByFCHLzqb)_
Fixes #25112
Clause-②: no
Metadata-protocol: none
## What changed
The `auth.magic_link` mail said "This link expires in 10 minutes" while
the link it carries lived 300 s: `magicLink()` was mounted without
`expiresIn` (so better-auth's own default applied) and `sendMagicLink`
passed a separate hard-coded `expiresInMinutes: 10`.
- `packages/plugins/plugin-auth/src/auth-manager.ts`: one local
constant, `magicLinkExpiresInSec = 5 * 60`, beside the mount. The mount
now passes `expiresIn: magicLinkExpiresInSec`, and the mail's
`expiresInMinutes` is `Math.round(magicLinkExpiresInSec / 60)`. The copy
and the link read one source.
- The link's **lifetime does not change**. It was 300 s, measured in the
installed better-auth 1.7.12 (`dist/plugins/magic-link/index.mjs`,
`expiresAt: new Date(Date.now() + (opts.expiresIn || 300) * 1e3)`), and
it stays 300 s, now stated rather than inherited, so a dependency bump
cannot move it under the mail.
- The seat's ruling on the card's open value (claim comment 6341542393),
executed as written: keep the measured 300 s, state it from one
constant, derive the mail from it. Lengthening the lifetime would relax
a sign-in credential and stays with the maintainer.
## Where the fix lives, and why not in plugin-email
All four locale rows of `auth.magic_link` in
`packages/plugins/plugin-email/src/templates/auth-templates.ts` (en-US,
zh-CN, ja-JP, es-ES), HTML and text faces, render the lifetime only from
`{{expiresInMinutes}}`. None hard-codes a number. The false value was
produced entirely by the producer in plugin-auth, so plugin-email does
not move and takes no changeset.
## Tests
- `auth-email-locale.test.ts`: the existing payload pin asserted the
false `10`; it now asserts `5`. A new pin asserts the mount states
`expiresIn: 300` and that the mail's `expiresInMinutes * 60` equals the
mount's `expiresIn`.
- Ablation, on head `145974256` with the fix committed first, through
`scripts/ablation-replace.mjs` (anchor hit 1, then 0; blob restored to
the HEAD blob `c3dd34d7bf34` both times):
1. `expiresInMinutes` set back to the literal `10`: 2 failed / 67 passed
(`expected 10 to be 5`, `expected 600 to be 300`).
2. `expiresIn` deleted from the mount: 1 failed / 68 passed (`expected
undefined to be 300`).
- `pnpm --filter @objectstack/plugin-auth build && typecheck && test`:
185 files passed, 3487 passed and 10 skipped.
## Gates
`dispatch-gates --commands` derived 70 commands for this diff, and all
70 exited 0. Reconciliation: `70 derived, 70 run, 0 NOT-MEASURED, 0
UNRUN`. Two of them first answered PREREQUISITE NOT MET (exit 3):
`check-plugin-teardown-shape --self-test` on a shallow clone, and
`check:dual-build-cjs-loads` without a full build. Both were re-run
after `git fetch --unshallow` and `pnpm build`, and both exited 0.
## Acceptance notes
- `plugin-email`'s template tests feed `auth.magic_link` the sample
value `expiresInMinutes: 10` (`plain-text-faces.test.ts`,
`auth-templates-locales.test.ts`). It is only render data and makes no
claim about the link's lifetime, so it is left as is.
- `check:auth-mount-ledger` tracks route mounts, not plugin options, so
it does not read this change.
---
_Generated by [Claude
Code](https://claude.ai/code/session_016g7nYP9wdNx1GDa5XDr7Uy)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016g7nYP9wdNx1GDa5XDr7Uy
Co-authored-by: Claude <noreply@anthropic.com>1 parent 80ec71d commit d609f60
3 files changed
Lines changed: 36 additions & 2 deletions
File tree
- .changeset
- packages/plugins/plugin-auth/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1052 | 1052 | | |
1053 | 1053 | | |
1054 | 1054 | | |
1055 | | - | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
1056 | 1068 | | |
1057 | 1069 | | |
1058 | 1070 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4216 | 4216 | | |
4217 | 4217 | | |
4218 | 4218 | | |
| 4219 | + | |
| 4220 | + | |
| 4221 | + | |
| 4222 | + | |
| 4223 | + | |
| 4224 | + | |
| 4225 | + | |
| 4226 | + | |
| 4227 | + | |
| 4228 | + | |
4219 | 4229 | | |
| 4230 | + | |
4220 | 4231 | | |
4221 | 4232 | | |
4222 | 4233 | | |
| |||
4280 | 4291 | | |
4281 | 4292 | | |
4282 | 4293 | | |
4283 | | - | |
| 4294 | + | |
4284 | 4295 | | |
4285 | 4296 | | |
4286 | 4297 | | |
| |||
0 commit comments