zenstack icon indicating copy to clipboard operation
zenstack copied to clipboard

`consumeOne` method not implemented — password reset broken with `better-auth >=1.7.0`

Open rasyidly opened this issue 3 months ago • 1 comments

Description

The zenstackAdapter does not implement the consumeOne method, which became required in [email protected]. This causes a BetterAuthError when users attempt to reset their password.

Error

BetterAuthError: Adapter "zenstack" must implement consumeOne for atomic single-use credential consumption.
    at factory.mjs:699:68

Steps to Reproduce

  1. Set up a project with better-auth@^1.6.26 (resolves to 1.7.x) and @zenstackhq/[email protected]
  2. Configure email/password with sendResetPassword
  3. Request a password reset email
  4. Click the reset link and submit the new password
  5. The error above is thrown

Expected Behavior

Password reset completes successfully. The consumeOne method should atomically find and delete the single-use token from the verification table.

Environment

  • @zenstackhq/better-auth: 3.9.2
  • better-auth: 1.7.1
  • Provider: PostgreSQL

Notes

  • [email protected] introduced consumeOne as a required adapter method for atomic single-use credential consumption (used for password reset tokens and potentially email verification tokens).
  • The peerDependencies allow better-auth: "^1.3.0", but the adapter does not work with 1.7.x.
  • As a workaround, I've pinned better-auth to ~1.6.26 to avoid the breaking change.
  • This likely affects all versions of @zenstackhq/better-auth.

Workaround

Pin better-auth to ~1.6.26 in your package.json:

"better-auth": "~1.6.26"

rasyidly avatar Aug 27 '26 05:08 rasyidly

I think this is fixed on the better-auth side now. The "must implement consumeOne" error only exists in @better-auth/core 1.7.0 to 1.7.2. Since 1.7.3 it falls back to findOne plus a guarded deleteMany when an adapter has no consumeOne. I ran the current zenstack adapter unchanged against core 1.7.6 and password reset worked: the first consume returns the row, the second returns null, and the row gets deleted.

So upgrading better-auth to 1.7.3 or later should clear it. A native consumeOne in the adapter would still be nice to have, but it's no longer needed for this to work.

drakeo338 avatar Sep 25 '26 08:09 drakeo338