[PR #1362] [MERGED] feat: custom generate token function for magic links #3776

Closed
opened 2026-03-13 11:11:25 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/1362
Author: @t3duk
Created: 2/5/2025
Status: Merged
Merged: 2/14/2025
Merged by: @Bekacru

Base: mainHead: feat-generate-token-magic-link


📝 Commits (6)

📊 Changes

3 files changed (+57 additions, -9 deletions)

View changed files

📝 docs/content/docs/plugins/magic-link.mdx (+20 -8)
📝 packages/better-auth/src/plugins/magic-link/index.ts (+7 -1)
📝 packages/better-auth/src/plugins/magic-link/magic-link.test.ts (+30 -0)

📄 Description

  • Adds generateToken configuration option to customise how tokens are generated.
  • Adds docs.
  • Adds tests.

This was suggested in #223 however for many months it has remained inactive. This PR implements their changes and some additional ones too.

I was considering adding more default functions, so that someone could pass generateToken: "notion to generate a token similar to Notion, however I have left this up to the developer to implement any kind of custom solution. This PR closes #1361 to allow the creation of custom generation of tokens, however does not implement any other default functions as requested.


🔄 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/1362 **Author:** [@t3duk](https://github.com/t3duk) **Created:** 2/5/2025 **Status:** ✅ Merged **Merged:** 2/14/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `feat-generate-token-magic-link` --- ### 📝 Commits (6) - [`f863fe2`](https://github.com/better-auth/better-auth/commit/f863fe2ad9a97dfc1f53ccb5b5df80e5e2c4e965) feat: ✨ add config option - [`78fd26b`](https://github.com/better-auth/better-auth/commit/78fd26bb9c74e73e999353fc7eaa616e704f676f) feat: ✨ add generate token functionallity - [`0465882`](https://github.com/better-auth/better-auth/commit/046588292930e000d5fb449ace2b542b892ca24d) test: add tests - [`54c7fca`](https://github.com/better-auth/better-auth/commit/54c7fca122c36c20742d7a0d5a3dc68f90134ec7) docs: add docs - [`6f132f8`](https://github.com/better-auth/better-auth/commit/6f132f84938d1370967c55ecd417245c4e16447a) chore: lint - [`e679fde`](https://github.com/better-auth/better-auth/commit/e679fdece3787f82f31c4ae9b0ba0900cbff56ca) docs: add warning ### 📊 Changes **3 files changed** (+57 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/magic-link.mdx` (+20 -8) 📝 `packages/better-auth/src/plugins/magic-link/index.ts` (+7 -1) 📝 `packages/better-auth/src/plugins/magic-link/magic-link.test.ts` (+30 -0) </details> ### 📄 Description - Adds `generateToken` configuration option to customise how tokens are generated. - Adds docs. - Adds tests. This was suggested in #223 however for many months it has remained inactive. This PR implements their changes and some additional ones too. I was considering adding more default functions, so that someone could pass `generateToken: "notion` to generate a token similar to Notion, however I have left this up to the developer to implement any kind of custom solution. This PR closes #1361 to allow the creation of custom generation of tokens, however does not implement any other default functions as requested. --- <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 11:11:26 -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#3776