Better Auth

BA

Better Auth

Join the community to ask questions about Better Auth and get answers from other members.

Join

bug-reports

help

Password not updating on resetPassword

Hi, I have been trying out better-auth with Elysia + SurrealDB (W/ Featured Community Adapter on Better Auth Site) + SvelteKit (SSG-only) and so far everything has worked out but I have started to face a weird issue related to the forget/reset password flow that I haven't been able to exactly pin down. I have been able to reach at the point where I am able to redirect the user to a proper page to reset the password, where I have them fill out a form, which when submitted, calls ...
Solution:
for now i just built the patched package, added it to my application, and tried the flow, and it has worked correctly

Best way to run code after user logs in/out

Looking for the best way to run code after a user logs in/out of the app. I need all the users info from the DB obj, the same info that would be returned with authClient.useSession() on a page...

Query tables created by better auth with kysely

Hey, I just set up better-auth with kysely and I noticed that I cannot query the database users etc manually as my typescript thinks my db instance does not have the correct types and thinks these tables do not exist. An example of what I mean is attached as an image below, How do I get my kysely instance to allow me to query all the tables created by better-auth
No description

How to Force Email-OTP Plugin to Use Redis Instead of PostgreSQL

In my Next.js project, I'm using the email-otp plugin for authentication. The primary database is PostgreSQL, and Redis is set up as a secondary storage. I assumed that sessions and OTP verification would be handled through Redis. However, when attempting to send an OTP, I get this error: ```...

Image not updating when using genericOAuth client.oauth2.link

When I sign up a new user with client.signIn.oauth2 the user info I get from my OAuth provider contains a image parameter that goes into my user image field in my db. But when I try linking an existing user using client.oauth2.link the user info I get from my OAuth provider still contains a image parameter but that info never gets updated in my user image field in my db. https://www.better-auth.com/docs/plugins/generic-oauth#linking-oauth-accounts...

Unable to send OTP

When executing sendVerificationOTP i get an error, all versions are up to date (drizzle-kit, drizzle-orm, better-auth) ```typescript const response = await auth.api.sendVerificationOTP({ body: { email, type: 'sign-in' },...

SolidJS useSession hook - refetch

I'm trying to use the solidjs hook for the store of the useSession hook and got everything working in terms of loading user data in etc, only thing i want to to is force a refetch of the session and noticed when debugging there is a refetch method attached to the hook but it's not declared in the types ie
const session = authClient.useSession();
await session().refetch();
const session = authClient.useSession();
await session().refetch();
...
Solution:
yeah it's intended

Callback when logging in with social.

Hi guys, is there a way to listen for a callback when a user does a signup using a social platform? Thanks

deleteUser questions

Hi there I am facing issues with user deletion and I'm not sure if there is a bug or if I misunderstand the concept. https://www.better-auth.com/docs/concepts/users-accounts#delete-user...

Replace or override baseEndpoints

I want to replace the built in resetPassword endpoint ``` const authenticator = betterAuth({ plugins: [ {...

Change email for unverified user ?

Is there a way to change the email of a user that hasn't been verified ? For exemple this cover the case a user register miss type the email and want to change to his good one.

MSSQL not working at all

Hi, is anyone using BetterAuth with MSSQL via Kysely? Migrations run fine for me, I can see the tables getting created in the DB, there is only 1 other table in it. When trying to login, I get: SERVER_ERROR: The data types text and nvarchar are incompatible in the equal to operator. ...

activeOrganizationId is null, but user is in Org.

Hey, I tried to get the activeOrganizatuinId with ```typescript const session = await auth.api.getSession({ headers: await headers(),...
No description

Multiple roles per user in Admin plugin

Hello, I'm trying to create an app using NextJS. I'm using Better-Auth with the admin plugin which seems good enough for what I need. However, I want to be able to provide users with different roles, but having multiple roles, e.g. Accounts, Sales etc. Using just the Admin plugin, how can I assign multiple roles to a user. I don't really want to use the organisation plugin, as I don't need that complexity just for multiple roles. Thanks!...

fetchOptions hooks not running

I'm seeing the following: - request specific onRequest/onResponse/onError/onSuccess run correctly - authClient onResponse (for all requests) runs correctly - authClient onRequest only runs if there is no request specific onRequest...

Dealing with generic OAuth provider that does not send email and account linking

Two part question: Hi all, we have a external OIDC IdP that does not reliably return an email in the token claims. When using the generic Oauth plugin, we get a Error Code: email_is_missing on callback. mapProfileToUser does not seem to get around this error. What's the best approach here? Second, we do get a reliable universal user identifier in the claims that can link a user to a specific human. Is there a way to customize the account linking feature based on something other than email but instead this unique user key?...

API Keys on Organization level?

hey guys, am new to better auth and saw there are plugins for organizations and for API Keys. according to the docs, API Keys are user scoped, would need them on Organization and team level, is that possible? if not, would go ahead and file a feature request 😉

Invalidate useSession()?

I'm using authClient.updateUser() to update user's name, but I want to make sure the new name is reflected in the useSession return value before performing a url change. Any way to make sure of that? Anything like Tanstack Query's .invalidateQueries()? I see there's refetch() on useSession() but it doesn't return a promise for me to make sure the refetch is completed....

Better Auth Microsoft OAuth - email_not_found Error

Hi team! I'm having an issue with Better Auth and Microsoft OAuth integration. When trying to authenticate with Microsoft, I'm getting this error: "Better Auth Error: We encountered an issue while processing your request. Error Code: email_not_found" ...
No description