Better Auth

BA

Better Auth

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

Join

bug-reports

help

useSession's refetch function is undefined after signing out in Expo

Basically what the title says. I've noticed that when I sign out, the refetch function is undefined. The problem is that if a user signs out and then signs in, the refetch function will remain undefined.

Organization Member Role | Wrong Type

When using Organization Plugin: As per this: https://www.better-auth.com/docs/plugins/organization#update-member-role ```tsx await authClient.organization.updateMemberRole({...

non-extractable CryptoKey cannot be exported as JWK

``` [15:13:03.504] INFO (91760): request: { "method": "GET", "url": "http://localhost:3000/api/auth/get-session",...

overrideUserInfoOnSignIn not working with Google

Steps to repro: 1. in auth.ts, under socialProviders: {google: ... } I've set overrideUserInfoOnSignIn: true 2. I go to my db, manually edit the user.name column to gibberish 3. Gibberish shows in session.user.name property in code 4. Sign out, sign in again (via Google OAuth), gibberish still showing in the db field....

Property 'callbackOAuth' does not exist on type 'InferAPI'

Hey, I use React-Router v7 framework mode. I have a custom endpoint, to validate OAuth Callbacks. Typescript says there is no such method. All I want, is to get Headers and do some modifications. Tried many things, but nothing. ...
No description

Incorrect Magic Link Base URL in Vercel

Magic Link URL always sends the deployment base url instead of the custom domain url in Vercel. I am using authClient for this. This does not happen with sending the reset password link....
No description

CRITICAL BUG IN PRODUCTION: authClient.useSession returns the session of a random user

I used authClient.useSession in the development environment, everything is working perfectly fine. When I tried to use it in production, it gets the session of a random user all of the time even if I log out & sign in again, it gets that random user. I "solved" this issue by getting the session on the server for now.......

segment.replace is not a function - Is this a bug?

I am getting this error. Although everything seems to work fine, I am a bit concerned (being an auth library, I don't want any surprises 🙂 ) I couldn't find any reference to this error anywhere....
No description

Expo plugin throws a type error on hono project.

Both the better-auth and the expo plugin is on the same version. Tried removing packages and re-installed it few times. Nothing helps

Demo better auth not found

https://demo.better-auth.com/ The demo site with Next and Better Auth is down and returns a 503 error on the client....
No description

findOneAndUpdate in mongodbAdapter returns inconsistent result shape

Hello, first of all I want to say that I love the framework. As the result I've have been migrating to it, but I encountered the following issue. I have also created github issue (https://github.com/better-auth/better-auth/issues/2508). There are more info in the page. Hi, I'm encountering an inconsistency with db.collection.findOneAndUpdate() in the mongodbAdapter. For some collections, it returns the updated document as expected. However, for others—like the users collection—it returns a result object in the following shape: { lastErrorObject: {n:1, updatedExisting: true}...

authClient.admin.removeUser doesn't trigger beforeDelete

I'm using the admin plugin. It has authClient.admin.removeUser functionality. the problem is that I set up user beforeDelete to delete all of the images from my s3 bucket before removing the user and it doesn't work. It works if and only if the user deletes himself manually. user deletion from the admin side: ```ts async function handleDelete() {...

Data Types MSSQL

Hi all. Not sure if this is a bug or just a lack of knowledge on my part. I have a next.js project using a mssql db and have generated/ migrated schema as per docs for all of the plugins. I've been setting up forgot password and update password but hitting an error with data types. For forgot password, the error occurs when the user has clicked on the link in the email (verifying the token??), and with update password, the error looks to be a call for accountId when it's writing the new password to the db. Error: The data types text and nvarchar are incompatible in the equal to operator. The schema has a number of fields as 'text' such as the tokens, accountId's etc but mssql no longer supports text as a data type so the db errors out on api calls that use these fields. I've manually updated the columns in my db to be varchar or nvarchar which has resolved the issue. I updated better-auth from 1.2.3 to 1.2.6 which also meant the twofactor verification failed as the verification table is also set up with text....

Not Equal filter not working on nextjs with prisma.

Hi guys, i've noticed a bug while trying to query all users except the ones with a specific role. On GitHub i've seen that a user already reported that: https://github.com/better-auth/better-auth/issues/2468 ...

db is not exposed in context

According to the docs at: https://www.better-auth.com/docs/concepts/plugins#what-can-a-plugin-do, the context object contains the db instance, like kysely. For me, it does not, please see the attachment to this post. Not only in my editor but also console logging the context object does not reveal the db instance. What do I need to do to expose the DB instance? I need to make joins due to performance reasons and I dont think the adapter is capable of it....
No description

Error Generating Types with openapi-typescript

Issue Description: Running the command bunx openapi-typescript --make-paths-enum --immutable results in the following error:
Error: #/paths/~1sign-in~1social/post/responses/200/content/application~1json: invalid property required. Expected Schema Object, got Array
Error: #/paths/~1sign-in~1social/post/responses/200/content/application~1json: invalid property required. Expected Schema Object, got Array
...
No description

Cannot cancel a trailing subscription

I'm trying to cancel a trialing subscription, by passing the subscription id in cancel function, but I receive a 400 response saying that the subscription cannot be found, but when I check my DB it is definitely there and the subscription Id matches. Am I supposed to cancel trials differently than active subscriptions?

Session schema missing from open API spec generation

I'm using the following code to generate open API documentation, however I noticed the reference to #/components/schemas/Session is missing? auth.api.generateOpenAPISchema()...
Next