[GH-ISSUE #6247] Support Async customPasswordCompromisedMessage for haveIBeenPwned Plugin #10457

Closed
opened 2026-04-13 06:37:07 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @bennajah on GitHub (Nov 23, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/6247

Is this suited for github?

  • Yes, this is suited for github

Yes. The customPasswordCompromisedMessage option in the haveIBeenPwned plugin currently does not support asynchronous functions. This makes it impossible to generate localized error messages based on the user’s active locale, since locale and translation loading in my setup rely on async functions.

Describe the solution you'd like

I would like customPasswordCompromisedMessage to support async functions. This would allow me to dynamically load the locale and translations before returning the appropriate error message.

haveIBeenPwned({
  customPasswordCompromisedMessage: async () => {
    const locale = await getLocale();
    const t = await getMessages({ locale });
    return t("Your password has been compromised. Please choose a new password.");
  },
});

Describe alternatives you've considered

Alternatively, following Better Auth’s existing pattern, allow defining static or dynamic error messages through an errorMessages option that accepts async functions:

errorMessages: async (ctx) => {
  const locale = await getLocale();
  const t = await getMessages({ locale });

  return {
    passwordCompromised: t("Your password has been compromised. Please choose a new password."),
    // ...other error messages
  };
}

Additional context

No response

Originally created by @bennajah on GitHub (Nov 23, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/6247 ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Yes. The customPasswordCompromisedMessage option in the haveIBeenPwned plugin currently does not support asynchronous functions. This makes it impossible to generate localized error messages based on the user’s active locale, since locale and translation loading in my setup rely on async functions. ### Describe the solution you'd like I would like customPasswordCompromisedMessage to support async functions. This would allow me to dynamically load the locale and translations before returning the appropriate error message. ```ts haveIBeenPwned({ customPasswordCompromisedMessage: async () => { const locale = await getLocale(); const t = await getMessages({ locale }); return t("Your password has been compromised. Please choose a new password."); }, }); ``` ### Describe alternatives you've considered Alternatively, following Better Auth’s existing pattern, allow defining static or dynamic error messages through an errorMessages option that accepts async functions: ```ts errorMessages: async (ctx) => { const locale = await getLocale(); const t = await getMessages({ locale }); return { passwordCompromised: t("Your password has been compromised. Please choose a new password."), // ...other error messages }; } ``` ### Additional context _No response_
GiteaMirror added the enhancementlocked labels 2026-04-13 06:37:07 -05:00
Author
Owner

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

tag @better-auth-agent if you would like an answer from the Agent

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3568350427 --> @better-auth-agent[bot] commented on GitHub (Nov 23, 2025): 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

@Ridhim-RR commented on GitHub (Nov 25, 2025):

@better-auth-agent can you look into this?

<!-- gh-comment-id:3573678847 --> @Ridhim-RR commented on GitHub (Nov 25, 2025): @better-auth-agent can you look into this?
Author
Owner

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

Hi there, thanks for raising this issue and providing so much context. Currently, the customPasswordCompromisedMessage option is designed to accept a static message (or a synchronous function returning a string), which means it doesn’t support async functions for dynamic localization. We understand that supporting async functions to load translations would be very useful for localized error messages, and this request aligns with our goal to improve flexibility in error-handling customization [1].

As a next step, we’ll bring this up with our team to evaluate how best to implement async support for this option in a future release. It might also be worth exploring whether incorporating an asynchronous errorMessages option—as you mentioned—could serve as an alternative until the plugin is updated, even though that pattern isn’t fully supported yet [2].

Could you share more details on your localization setup so our team can factor in any specific requirements? Tag @better-auth-agent if you would like an answer from the Agent.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3573679381 --> @better-auth-agent[bot] commented on GitHub (Nov 25, 2025): Hi there, thanks for raising this issue and providing so much context. Currently, the customPasswordCompromisedMessage option is designed to accept a static message (or a synchronous function returning a string), which means it doesn’t support async functions for dynamic localization. We understand that supporting async functions to load translations would be very useful for localized error messages, and this request aligns with our goal to improve flexibility in error-handling customization [[1]](https://www.better-auth.com/docs/reference/contributing). As a next step, we’ll bring this up with our team to evaluate how best to implement async support for this option in a future release. It might also be worth exploring whether incorporating an asynchronous errorMessages option—as you mentioned—could serve as an alternative until the plugin is updated, even though that pattern isn’t fully supported yet [[2]](https://www.better-auth.com/docs/plugins/have-i-been-pwned). Could you share more details on your localization setup so our team can factor in any specific requirements? 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 (Feb 24, 2026):

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

Issue Summary:

  • You requested async support for the haveIBeenPwned plugin's customPasswordCompromisedMessage to allow dynamic, localized error messages.
  • Currently, only static or synchronous messages are supported.
  • The maintainers agree that async support would improve flexibility.
  • There has been discussion about possibly adding an async errorMessages option.
  • The team has asked you for more details on your localization setup to better address the request.

Next Steps:

  • Please let me know if this issue is still relevant to the latest version of better-auth and provide any additional details about your localization setup.
  • If I don’t hear back within 7 days, this issue will be automatically closed.

Thank you for your understanding and contribution!

<!-- gh-comment-id:3953205618 --> @dosubot[bot] commented on GitHub (Feb 24, 2026): Hi, @bennajah. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You requested async support for the haveIBeenPwned plugin's customPasswordCompromisedMessage to allow dynamic, localized error messages. - Currently, only static or synchronous messages are supported. - The maintainers agree that async support would improve flexibility. - There has been discussion about possibly adding an async errorMessages option. - The team has asked you for more details on your localization setup to better address the request. **Next Steps:** - Please let me know if this issue is still relevant to the latest version of better-auth and provide any additional details about your localization setup. - If I don’t hear back within 7 days, this issue will be automatically closed. 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#10457