[PR #4122] [CLOSED] feat/last-used-social-provider #5200

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

📋 Pull Request Information

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

Base: canaryHead: feat/last-used-social-provider


📝 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

7 files changed (+270 additions, -0 deletions)

View changed files

📝 docs/components/sidebar-content.tsx (+6 -0)
docs/content/docs/plugins/last-login-method.mdx (+110 -0)
📝 packages/better-auth/src/plugins/index.ts (+1 -0)
packages/better-auth/src/plugins/last-login-method/client.ts (+9 -0)
packages/better-auth/src/plugins/last-login-method/index.ts (+92 -0)
packages/better-auth/src/plugins/last-login-method/types.ts (+31 -0)
📝 packages/better-auth/src/social-providers/social.test.ts (+21 -0)

📄 Description

This PR introduces a new plugin lastSocialProvider which records which social provider a user used to log in the last time they logged in.


Summary by cubic

Adds a new lastSocialProvider plugin that remembers the user’s last social login provider. Exposes a simple endpoint and client hook so apps can preselect the provider on next sign-in.

  • New Features
    • Server plugin sets an httpOnly cookie with the provider ID after /callback/:provider (name and maxAge are configurable; defaults: better-auth.last_used_social, 5 days).
    • Adds GET /last-used-social endpoint (client: client.lastUsedSocial) returning the provider ID or null.
    • Client plugin (lastSocialProviderClient) with server typing inference; exported via plugins index.
    • Documentation page and sidebar link added; tests cover null-before-login and persisted value after Google sign-in.

🔄 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/4122 **Author:** [@frectonz](https://github.com/frectonz) **Created:** 8/21/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/last-used-social-provider` --- ### 📝 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 **7 files changed** (+270 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/components/sidebar-content.tsx` (+6 -0) ➕ `docs/content/docs/plugins/last-login-method.mdx` (+110 -0) 📝 `packages/better-auth/src/plugins/index.ts` (+1 -0) ➕ `packages/better-auth/src/plugins/last-login-method/client.ts` (+9 -0) ➕ `packages/better-auth/src/plugins/last-login-method/index.ts` (+92 -0) ➕ `packages/better-auth/src/plugins/last-login-method/types.ts` (+31 -0) 📝 `packages/better-auth/src/social-providers/social.test.ts` (+21 -0) </details> ### 📄 Description This PR introduces a new plugin `lastSocialProvider` which records which social provider a user used to log in the last time they logged in. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds a new lastSocialProvider plugin that remembers the user’s last social login provider. Exposes a simple endpoint and client hook so apps can preselect the provider on next sign-in. - New Features - Server plugin sets an httpOnly cookie with the provider ID after /callback/:provider (name and maxAge are configurable; defaults: better-auth.last_used_social, 5 days). - Adds GET /last-used-social endpoint (client: client.lastUsedSocial) returning the provider ID or null. - Client plugin (lastSocialProviderClient) with server typing inference; exported via plugins index. - Documentation page and sidebar link added; tests cover null-before-login and persisted value after Google sign-in. <!-- 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:13:50 -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#5200