[PR #5552] [MERGED] feat(magic-link): add allowedAttempts options #6078

Closed
opened 2026-03-13 12:46:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5552
Author: @Phillip9587
Created: 10/24/2025
Status: Merged
Merged: 2/11/2026
Merged by: @himself65

Base: canaryHead: feat/magic-link-attempts-option


📝 Commits (6)

  • 498991c feat(magic-link): add allowedAttempts options
  • 5b7f3e4 chore: improve
  • 5d01ae5 fix: code
  • be80948 fix: parse
  • 5f896dc fix: use redirect with error
  • 9ceab06 Merge branch 'canary' into feat/magic-link-attempts-option

📊 Changes

3 files changed (+294 additions, -6 deletions)

View changed files

📝 docs/content/docs/plugins/magic-link.mdx (+2 -0)
📝 packages/better-auth/src/plugins/magic-link/index.ts (+31 -5)
📝 packages/better-auth/src/plugins/magic-link/magic-link.test.ts (+261 -1)

📄 Description

Closes #5550


Summary by cubic

Add an allowedAttempts option to the Magic Link plugin to control how many times a token can be verified. Tokens now track and increment attempts; exceeding the limit deletes the token and redirects with ?error=ATTEMPTS_EXCEEDED, while expired tokens still return ?error=EXPIRED_TOKEN.

  • New Features
    • New option: allowedAttempts (default: 1; Infinity allows unlimited attempts).
    • Store and increment attempt count in the verification value.
    • On limit, delete the token and redirect with ATTEMPTS_EXCEEDED; docs and tests updated (default, custom counts, Infinity, expiration).

Written for commit 9ceab06644. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5552 **Author:** [@Phillip9587](https://github.com/Phillip9587) **Created:** 10/24/2025 **Status:** ✅ Merged **Merged:** 2/11/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `feat/magic-link-attempts-option` --- ### 📝 Commits (6) - [`498991c`](https://github.com/better-auth/better-auth/commit/498991cea8631347f61b805cd468a662e829dfdf) feat(magic-link): add allowedAttempts options - [`5b7f3e4`](https://github.com/better-auth/better-auth/commit/5b7f3e48b705904aa9825477520af212accee0bf) chore: improve - [`5d01ae5`](https://github.com/better-auth/better-auth/commit/5d01ae5fd641f6063527db5732517f1aa7c280ab) fix: code - [`be80948`](https://github.com/better-auth/better-auth/commit/be8094835629d589069a00dd62d04735c3cf6d48) fix: parse - [`5f896dc`](https://github.com/better-auth/better-auth/commit/5f896dc123905043823d0b98ac3ef8b289144c51) fix: use redirect with error - [`9ceab06`](https://github.com/better-auth/better-auth/commit/9ceab06644361a609fced69f5f59c52f1135247e) Merge branch 'canary' into feat/magic-link-attempts-option ### 📊 Changes **3 files changed** (+294 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/magic-link.mdx` (+2 -0) 📝 `packages/better-auth/src/plugins/magic-link/index.ts` (+31 -5) 📝 `packages/better-auth/src/plugins/magic-link/magic-link.test.ts` (+261 -1) </details> ### 📄 Description Closes #5550 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add an allowedAttempts option to the Magic Link plugin to control how many times a token can be verified. Tokens now track and increment attempts; exceeding the limit deletes the token and redirects with ?error=ATTEMPTS_EXCEEDED, while expired tokens still return ?error=EXPIRED_TOKEN. - **New Features** - New option: allowedAttempts (default: 1; Infinity allows unlimited attempts). - Store and increment attempt count in the verification value. - On limit, delete the token and redirect with ATTEMPTS_EXCEEDED; docs and tests updated (default, custom counts, Infinity, expiration). <sup>Written for commit 9ceab06644361a609fced69f5f59c52f1135247e. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:46:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#6078