[PR #4128] [CLOSED] feat/last-login-method #22105

Closed
opened 2026-04-15 20:49:28 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4128
Author: @frectonz
Created: 8/21/2025
Status: Closed

Base: canaryHead: feat/last-login-method


📝 Commits (10+)

  • 0ae9b77 feat: implement getting the last used social provider
  • 6ed45de test(last-social-provider): add test for getting the last used social provider
  • 639a93d docs: add last social provider
  • 1197a16 docs: add last social provider link to sidebar
  • 513f990 fix(docs): use authClient
  • 4c105d3 fix(last-social-provider): provider id is nullable
  • 9fb9959 fix(last-social-provider): check for trusted provider ids
  • 045362f docs(last-social-provider): document trustedProviderIds
  • 85ca1c2 chore(last-login-method): rename to last-login-method
  • 5dbcf86 chore(last-login-method): rename to lastLoginMethod

📊 Changes

19 files changed (+536 additions, -67 deletions)

View changed files

📝 demo/nextjs/components/sign-in.tsx (+4 -1)
📝 demo/nextjs/lib/auth-client.ts (+2 -0)
📝 demo/nextjs/lib/auth.ts (+2 -0)
📝 docs/components/sidebar-content.tsx (+6 -0)
docs/content/docs/plugins/last-login-method.mdx (+113 -0)
📝 packages/better-auth/src/api/routes/email-verification.test.ts (+27 -12)
📝 packages/better-auth/src/api/routes/sign-in.test.ts (+24 -1)
📝 packages/better-auth/src/api/routes/sign-up.test.ts (+47 -0)
📝 packages/better-auth/src/plugins/anonymous/anon.test.ts (+8 -3)
📝 packages/better-auth/src/plugins/email-otp/email-otp.test.ts (+13 -2)
📝 packages/better-auth/src/plugins/generic-oauth/generic-oauth.test.ts (+13 -7)
📝 packages/better-auth/src/plugins/index.ts (+1 -0)
packages/better-auth/src/plugins/last-login-method/client.ts (+28 -0)
packages/better-auth/src/plugins/last-login-method/index.ts (+116 -0)
packages/better-auth/src/plugins/last-login-method/types.ts (+30 -0)
📝 packages/better-auth/src/plugins/magic-link/magic-link.test.ts (+17 -11)
📝 packages/better-auth/src/plugins/phone-number/phone-number.test.ts (+39 -22)
📝 packages/better-auth/src/plugins/siwe/siwe.test.ts (+25 -8)
📝 packages/better-auth/src/social-providers/social.test.ts (+21 -0)

📄 Description

Summary by cubic

Adds a last-login-method plugin that remembers the user’s last social login provider and exposes an endpoint to retrieve it. Improves login UX (e.g., preselect the provider) and includes client support, docs, and tests.

  • New Features
    • Server plugin lastLoginMethod:
      • Sets an httpOnly cookie after /callback/ if the provider is enabled or in trustedProviderIds.
      • GET /last-used-login-method returns the provider ID (string) or null.
      • Options: cookieName ("better-auth.last_used_login_method"), maxAge (5 days), trustedProviderIds ([]).
    • Client plugin lastLoginMethodClient to call authClient.lastUsedLoginMethod(...).
    • Docs added with sidebar link; tests cover null case and remembered provider.

🔄 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/4128 **Author:** [@frectonz](https://github.com/frectonz) **Created:** 8/21/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/last-login-method` --- ### 📝 Commits (10+) - [`0ae9b77`](https://github.com/better-auth/better-auth/commit/0ae9b77d53068355a16ce5d2f54b64413346287a) feat: implement getting the last used social provider - [`6ed45de`](https://github.com/better-auth/better-auth/commit/6ed45ded3175c2cba5023c908a8207ddaee0d8a2) test(last-social-provider): add test for getting the last used social provider - [`639a93d`](https://github.com/better-auth/better-auth/commit/639a93db70341ca2b3e50bcfd1336c41d52a2818) docs: add last social provider - [`1197a16`](https://github.com/better-auth/better-auth/commit/1197a16b72e5ac8dadc9ad84952f92f7d070081d) docs: add last social provider link to sidebar - [`513f990`](https://github.com/better-auth/better-auth/commit/513f9903da8753e1977ae3c6237a952a852e91b8) fix(docs): use `authClient` - [`4c105d3`](https://github.com/better-auth/better-auth/commit/4c105d37fe1ac049ae6bc78d82453d98926cec0f) fix(last-social-provider): provider id is nullable - [`9fb9959`](https://github.com/better-auth/better-auth/commit/9fb9959616e4e0b4eda9b391d745e268b7a7aa1a) fix(last-social-provider): check for trusted provider ids - [`045362f`](https://github.com/better-auth/better-auth/commit/045362f4f2be266de88ee4725e496d10567871d0) docs(last-social-provider): document `trustedProviderIds` - [`85ca1c2`](https://github.com/better-auth/better-auth/commit/85ca1c24a0a6e74b8bf4c9ec374bfaabe001befc) chore(last-login-method): rename to `last-login-method` - [`5dbcf86`](https://github.com/better-auth/better-auth/commit/5dbcf86a6fefaf465d6daa27204716ec097ac98e) chore(last-login-method): rename to `lastLoginMethod` ### 📊 Changes **19 files changed** (+536 additions, -67 deletions) <details> <summary>View changed files</summary> 📝 `demo/nextjs/components/sign-in.tsx` (+4 -1) 📝 `demo/nextjs/lib/auth-client.ts` (+2 -0) 📝 `demo/nextjs/lib/auth.ts` (+2 -0) 📝 `docs/components/sidebar-content.tsx` (+6 -0) ➕ `docs/content/docs/plugins/last-login-method.mdx` (+113 -0) 📝 `packages/better-auth/src/api/routes/email-verification.test.ts` (+27 -12) 📝 `packages/better-auth/src/api/routes/sign-in.test.ts` (+24 -1) 📝 `packages/better-auth/src/api/routes/sign-up.test.ts` (+47 -0) 📝 `packages/better-auth/src/plugins/anonymous/anon.test.ts` (+8 -3) 📝 `packages/better-auth/src/plugins/email-otp/email-otp.test.ts` (+13 -2) 📝 `packages/better-auth/src/plugins/generic-oauth/generic-oauth.test.ts` (+13 -7) 📝 `packages/better-auth/src/plugins/index.ts` (+1 -0) ➕ `packages/better-auth/src/plugins/last-login-method/client.ts` (+28 -0) ➕ `packages/better-auth/src/plugins/last-login-method/index.ts` (+116 -0) ➕ `packages/better-auth/src/plugins/last-login-method/types.ts` (+30 -0) 📝 `packages/better-auth/src/plugins/magic-link/magic-link.test.ts` (+17 -11) 📝 `packages/better-auth/src/plugins/phone-number/phone-number.test.ts` (+39 -22) 📝 `packages/better-auth/src/plugins/siwe/siwe.test.ts` (+25 -8) 📝 `packages/better-auth/src/social-providers/social.test.ts` (+21 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Adds a last-login-method plugin that remembers the user’s last social login provider and exposes an endpoint to retrieve it. Improves login UX (e.g., preselect the provider) and includes client support, docs, and tests. - **New Features** - Server plugin lastLoginMethod: - Sets an httpOnly cookie after /callback/<provider> if the provider is enabled or in trustedProviderIds. - GET /last-used-login-method returns the provider ID (string) or null. - Options: cookieName ("better-auth.last_used_login_method"), maxAge (5 days), trustedProviderIds ([]). - Client plugin lastLoginMethodClient to call authClient.lastUsedLoginMethod(...). - Docs added with sidebar link; tests cover null case and remembered provider. <!-- 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-04-15 20:49:28 -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#22105