Incorrect types for databaseHooks that were called with updateManyWithHooks #956

Closed
opened 2026-03-13 08:11:59 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @billdotdev on GitHub (Apr 1, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

call authenticator.api.resetPassword()

const auth = betterAuth({
	emailAndPassword: {
		enabled: true,
		async sendResetPassword(data, request) {
			console.log(data);
		}
	},
	databaseHooks: {
		account: {
			update: {
				async after(account, context) {
					console.log(account, context);
				}
			}
		}
	}
});

await auth.api.forgetPassword({
	body: {
		email: 'example@mail.com'
	}
});

await auth.api.resetPassword({
	body: {
		token: 'token',
		newPassword: 'password'
	}
});

Current vs. Expected behavior

account returned from databaseHooks.account.update.after is a number but type suggests that it is an account.
It seems like updateManyWithHooks is only used in updatePassword

What version of Better Auth are you using?

1.2.5

Provide environment information

- OS: Mac
- Browser: chrome

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

Types, Backend

Auth config (if applicable)

import { betterAuth } from "better-auth";
export const auth = betterAuth({
  emailAndPassword: {
    enabled: true,
    async sendResetPassword(data, request) {
      console.log(data);
    },
  },
  databaseHooks: {
    account: {
      update: {
        async after(account, context) {
          console.log(account, context);
        },
      },
    },
  },
});

Additional context

No response

Originally created by @billdotdev on GitHub (Apr 1, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce call `authenticator.api.resetPassword()` ``` const auth = betterAuth({ emailAndPassword: { enabled: true, async sendResetPassword(data, request) { console.log(data); } }, databaseHooks: { account: { update: { async after(account, context) { console.log(account, context); } } } } }); await auth.api.forgetPassword({ body: { email: 'example@mail.com' } }); await auth.api.resetPassword({ body: { token: 'token', newPassword: 'password' } }); ``` ### Current vs. Expected behavior account returned from `databaseHooks.account.update.after` is a number but type suggests that it is an account. It seems like `updateManyWithHooks` is only used in `updatePassword` ### What version of Better Auth are you using? 1.2.5 ### Provide environment information ```bash - OS: Mac - Browser: chrome ``` ### Which area(s) are affected? (Select all that apply) Types, Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; export const auth = betterAuth({ emailAndPassword: { enabled: true, async sendResetPassword(data, request) { console.log(data); }, }, databaseHooks: { account: { update: { async after(account, context) { console.log(account, context); }, }, }, }, }); ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 08:11:59 -05:00
Author
Owner

@Kinfe123 commented on GitHub (Apr 2, 2025):

@billdotdev do you find this issue still persists ?

@Kinfe123 commented on GitHub (Apr 2, 2025): @billdotdev do you find this issue still persists ?
Author
Owner

@billdotdev commented on GitHub (Apr 3, 2025):

Yes, I am also using the prismaAdapter

@billdotdev commented on GitHub (Apr 3, 2025): Yes, I am also using the prismaAdapter
Author
Owner

@dosubot[bot] commented on GitHub (Jul 3, 2025):

Hi, @billdotdev. I'm Dosu, and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • Incorrect type definitions for databaseHooks in updateManyWithHooks.
  • account is returned as a number instead of an account object.
  • Issue affects both types and backend functionality in version 1.2.5.
  • You confirmed the issue persists and mentioned using the prismaAdapter.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of the better-auth repository. If so, you can keep the discussion open by commenting here.
  • If there is no further activity, this issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Jul 3, 2025): Hi, @billdotdev. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale. **Issue Summary:** - Incorrect type definitions for `databaseHooks` in `updateManyWithHooks`. - `account` is returned as a number instead of an account object. - Issue affects both types and backend functionality in version 1.2.5. - You confirmed the issue persists and mentioned using the prismaAdapter. **Next Steps:** - Please confirm if this issue is still relevant to the latest version of the better-auth repository. If so, you can keep the discussion open by commenting here. - If there is no further activity, this issue will be automatically closed in 7 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#956