[GH-ISSUE #6128] lastLoginMethod not set when logging in with Passkey #10426

Closed
opened 2026-04-13 06:32:56 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @matteobadini on GitHub (Nov 20, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/6128

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Login with Passkey
  2. Check Last Login Method
  3. Result is an empty string

Current vs. Expected behavior

better-auth.last_used_login_method cookie is not set -> should be "passkey"

What version of Better Auth are you using?

1.3.34

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000",
    "release": "25.1.0",
    "cpuCount": 8,
    "cpuModel": "Apple M1 Pro",
    "totalMemory": "16.00 GB",
    "freeMemory": "0.71 GB"
  },
  "node": {
    "version": "v22.20.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "10.9.3"
  },
  "frameworks": [
    {
      "name": "next",
      "version": "16.0.3"
    },
    {
      "name": "react",
      "version": "19.2.0"
    },
    {
      "name": "hono",
      "version": "^4.10.6"
    }
  ],
  "databases": [
    {
      "name": "pg",
      "version": "^8.16.0"
    },
    {
      "name": "drizzle",
      "version": "^0.44.7"
    },
    {
      "name": "@neondatabase/serverless",
      "version": "^1.0.2"
    }
  ],
  "betterAuth": {
    "version": "^1.3.34",
    "config": null
  }
}

Which area(s) are affected? (Select all that apply)

Backend, Client

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
  lastLoginMethod()
});

Additional context

Same when storeInDatabase: true option is set

I'm willing to create a PR if needed :)

Originally created by @matteobadini on GitHub (Nov 20, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/6128 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Login with Passkey 2. Check Last Login Method 3. Result is an empty string ### Current vs. Expected behavior better-auth.last_used_login_method cookie is not set -> should be "passkey" ### What version of Better Auth are you using? 1.3.34 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000", "release": "25.1.0", "cpuCount": 8, "cpuModel": "Apple M1 Pro", "totalMemory": "16.00 GB", "freeMemory": "0.71 GB" }, "node": { "version": "v22.20.0", "env": "development" }, "packageManager": { "name": "npm", "version": "10.9.3" }, "frameworks": [ { "name": "next", "version": "16.0.3" }, { "name": "react", "version": "19.2.0" }, { "name": "hono", "version": "^4.10.6" } ], "databases": [ { "name": "pg", "version": "^8.16.0" }, { "name": "drizzle", "version": "^0.44.7" }, { "name": "@neondatabase/serverless", "version": "^1.0.2" } ], "betterAuth": { "version": "^1.3.34", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Backend, Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, lastLoginMethod() }); ``` ### Additional context Same when `storeInDatabase: true` option is set I'm willing to create a PR if needed :)
GiteaMirror added the lockedbug labels 2026-04-13 06:32:56 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 20, 2025):

Thanks for reporting this issue with the passkey login not setting the last used login method. It appears similar to a recently reported behavior with other authentication methods where the lastLoginMethod field remains an empty string instead of reflecting the actual method (as seen with SIWE, where the expected output was “SIWE”) [1]. In your case, the expected value “passkey” isn’t being stored.

Here are a few steps to troubleshoot and potentially resolve the issue:

  1. Verify that your auth configuration properly includes the lastLoginMethod setup so that it captures the passkey method. You might try explicitly checking that the login flow for passkeys calls the related middleware or logic that sets the cookie or database field.
  2. If you already have storeInDatabase: true set and the issue persists, it could be that the passkey handling logic isn’t updating the last used method appropriately.
  3. Consider reviewing your implementation against our latest docs and confirming that the passkey flow follows the same pattern as other methods. If you find a discrepancy, a PR would be very welcome.

Does this help clarify the next steps? Tag @better-auth-agent if you would like an answer from the Agent.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3558176348 --> @better-auth-agent[bot] commented on GitHub (Nov 20, 2025): Thanks for reporting this issue with the passkey login not setting the last used login method. It appears similar to a recently reported behavior with other authentication methods where the lastLoginMethod field remains an empty string instead of reflecting the actual method (as seen with SIWE, where the expected output was “SIWE”) [[1]](https://github.com/better-auth/better-auth/issues/4125). In your case, the expected value “passkey” isn’t being stored. Here are a few steps to troubleshoot and potentially resolve the issue: 1. Verify that your auth configuration properly includes the lastLoginMethod setup so that it captures the passkey method. You might try explicitly checking that the login flow for passkeys calls the related middleware or logic that sets the cookie or database field. 2. If you already have storeInDatabase: true set and the issue persists, it could be that the passkey handling logic isn’t updating the last used method appropriately. 3. Consider reviewing your implementation against our latest docs and confirming that the passkey flow follows the same pattern as other methods. If you find a discrepancy, a PR would be very welcome. Does this help clarify the next steps? Tag @better-auth-agent if you would like an answer from the Agent. <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@dosubot[bot] commented on GitHub (Nov 20, 2025):

Hi @matteobadini! I'm Dosu and I’m helping the better-auth team.

This is a known gap in the current implementation. The lastLoginMethod plugin only sets the better-auth.last_used_login_method cookie if it recognizes the login path as a supported method (like email or OAuth), but Passkey endpoints are not included in its default detection logic. As a result, logging in with Passkey does not update the cookie or database field, which is why you see an empty string after Passkey login. This matches similar issues reported for other providers where the path matching logic misses certain flows (example).

To fix this, you can provide a custom customResolveMethod to the lastLoginMethod plugin that recognizes Passkey login endpoints (such as /passkey/verify-authentication) and returns "passkey" when appropriate. For example:

lastLoginMethod({
  customResolveMethod: (ctx) => {
    if (ctx.path === "/passkey/verify-authentication") return "passkey";
    // fallback to default logic for other methods
    // ... (copy from the plugin's defaultResolveMethod if needed)
    return null;
  },
  storeInDatabase: true // if you want DB sync
})

This will ensure the cookie (and DB field, if enabled) is set to "passkey" after a successful Passkey login.

If you want to contribute a more general fix, you could extend the plugin's default resolver to include Passkey endpoints, or submit a PR to add first-class Passkey support to the plugin's detection logic.

Let me know if you want a more detailed example or have questions about customizing the resolver!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3558211333 --> @dosubot[bot] commented on GitHub (Nov 20, 2025): <!-- Greeting --> Hi @matteobadini! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This is a known gap in the current implementation. The lastLoginMethod plugin only sets the `better-auth.last_used_login_method` cookie if it recognizes the login path as a supported method (like email or OAuth), but Passkey endpoints are not included in its default detection logic. As a result, logging in with Passkey does not update the cookie or database field, which is why you see an empty string after Passkey login. This matches similar issues reported for other providers where the path matching logic misses certain flows ([example](https://github.com/better-auth/better-auth/issues/5970)). To fix this, you can provide a custom `customResolveMethod` to the `lastLoginMethod` plugin that recognizes Passkey login endpoints (such as `/passkey/verify-authentication`) and returns `"passkey"` when appropriate. For example: ```ts lastLoginMethod({ customResolveMethod: (ctx) => { if (ctx.path === "/passkey/verify-authentication") return "passkey"; // fallback to default logic for other methods // ... (copy from the plugin's defaultResolveMethod if needed) return null; }, storeInDatabase: true // if you want DB sync }) ``` This will ensure the cookie (and DB field, if enabled) is set to `"passkey"` after a successful Passkey login. If you want to contribute a more general fix, you could extend the plugin's default resolver to include Passkey endpoints, or submit a PR to add first-class Passkey support to the plugin's detection logic. Let me know if you want a more detailed example or have questions about customizing the resolver! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/2efc48b5-b44c-45dd-949b-277ec9b95692?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/2efc48b5-b44c-45dd-949b-277ec9b95692?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/2efc48b5-b44c-45dd-949b-277ec9b95692?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/2efc48b5-b44c-45dd-949b-277ec9b95692?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/2efc48b5-b44c-45dd-949b-277ec9b95692?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/2efc48b5-b44c-45dd-949b-277ec9b95692?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/2efc48b5-b44c-45dd-949b-277ec9b95692?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/6128)
Author
Owner

@GautamBytes commented on GitHub (Nov 21, 2025):

working on it!

<!-- gh-comment-id:3561906991 --> @GautamBytes commented on GitHub (Nov 21, 2025): working on it!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#10426