Better Auth

BA

Better Auth

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

Join

bug-reports

help

Org - Dynamic Access Control - Role deletion issues

1. Invite an user with a dynamic role, then delete the role. But the user can still accept the invitation and is assigned the deleted role. 2. As i mentioned here, https://discord.com/channels/1288403910284935179/1417211182338674789
In Organization dynamic access control, deleting an Orgrole (auth.api.deleteOrgRole) leaves the members associated with it dangling. Providing a fallback role or preventing deletion if the role is associated with any member or some kinda handling for this case.
In Organization dynamic access control, deleting an Orgrole (auth.api.deleteOrgRole) leaves the members associated with it dangling. Providing a fallback role or preventing deletion if the role is associated with any member or some kinda handling for this case.
...

Org Dynamic Access Control - updateOrgRole error

Issue: user with Owner role cant updateOrgRole For an org say Org1, I changed the role of an existing user2 from Member->Owner.
User2 (owner) can create new OrgRole with all the permissions, but cant update,...
Solution:
seems fixed in v1.3.10-beta.5 - i am on latest stable release - v1.3.9

inferAdditionalFields not working

Attaching images showing that the auth type provided to the plugin contains all additional fields but it is never being inferred by the client.
No description

useSession causes hundreds/thousands of duplicate requests under slow network + async RSC

No, this is not some bad React code that is causing infinite re-renders or something. If you set nework throttle to 3G and render a client componnet in an async react server component in Next.js. And call useSession in the top layout. You can see thousands of requests to /api/auth/get-session (probably during hydration process). It even causes random hydration mismatch warnings if you display UI based on isPending of useSession under the same conditions. I've made a very thorough GitHub issue that explains this with a repo that let's you test what I'm saying....

NestJS app hangs on startup after upgrading Better Auth from 1.3.9+

I’m running into an issue when upgrading Better Auth in a NestJS API. Current working version: 1.3.8 Issue starts happening from: 1.3.9 (including 1.3.10-beta.1)...

Empty plugin array throws type inference into a never state

I setup a project recently and noticed I couldn't get inference on my Session types. After some time i figured out that having the plugin array empty on Better-auth's instance setup was the culprit. here's a minimal repro that should yield a type error from the LSP perceptive. ```typescript...
No description

Prisma Adapter Issues

We customise all our tables to be snake_case via mappings (https://www.better-auth.com/docs/concepts/database#custom-tables) Today we switched from Postgres (Kysely) to Prisma Postgres (Prisma Adapter). We have noticed several issues:...

Stripe not handling subscription.update events from Billing Portal.

As the title states. I create a subscription for my user. If the user cancels their subscription from their billing portal, this isnt reflected in the database. Instead, I have to use the cancel() and restore() functions from better-auth. Is this normal? Better auth config: `export const auth = betterAuth({...

useActiveMember hook not updating when organization switch happens.

In my system an user have multiple roles in multiple organizations, when I switch organization, I was expecting it get the current active member, and then I want to get role from it, and hide/show sidenav links based on members org roles. The problem is, if I print activeMember, it still print old member, even after I switch organization. Can you Redmond a solution to make it dynamic? ...

Creating a subscription in stripe fails.

I am trying to create a user and the creation process goes smoothly, the user is created in the database and also the stripe customer id is then updated in the database. But then I need to create a subscription for the user and I am using the auth.api.upgradeSubscription as mentioned in the docs. This fails. const subscription = await auth.api.upgradeSubscription({...

authClient.organization.checkRolePermission(...) -> now a promise?

`const canCreateProject = authClient.organization.checkRolePermission({ permissions: { organization: ["delete"], }, role: "admin",...

Uncaught SyntaxError

I am on the latest version 1.3.8. and getting this error causing the whole app screen to go blank. I installed and uninstalled it , downgraded and reversed it still the same problem. Am using react vite and express. Found it in the console Uncaught SyntaxError: 'super' keyword unexpected here (at better-auth_client_plugins.js?v=94705b18:178:9)...

beforeAddMember-hook not called on organization creation

As the title says, the beforeAddMember is not called for the "owner member" when creating an organization. This causes issues when eg. enriching member objects in the hooks. In our case, we enrich members with a required additional field in the hook. Thus, this issue prohibits the "owner member" from being created....

1.3.8 won't work with expo anymore

1.3.7 worked with expo, but 1.3.8 doesn't, and gives this error: ``` iOS Bundling failed 7588ms node_modules/expo-router/entry.js (1661 modules) The package at "node_modules/jose/dist/node/esm/runtime/decrypt.js" attempted to import the Node standard library module "node:crypto"....

Bug with admin plugin and renamed fields

I'm using the admin plugin, which adds a "role" field, I wanted to rename it "better_auth_role", so in the BetterAuth conf I did eg ``` user: { modelName: "usersTable", fields: {...

Missing functions in organization plugin: getActiveOrganization and listOrganziations.

getActiveOrganization is not implemented in the plugin. I can find listOrganizations in the sourcecode, bud when I do auth.api.listOrganizations (server side) it sells me the property does not exist on type 'InferApi'. Any advice here? ...

Wrong schema generated in drizzle

in additional field if you add type: "string[]" and then default value an empty array when generating schema it doesnt fill the default value in drizzle with an empty array causing error
No description

Casing not Working with CLI

My auth.ts looks like this: ```ts import { db } from "$lib/server/db"; import { betterAuth } from "better-auth"; ...

Incorrect docs: uauth.api.listActiveSubscriptions does not exist

The documentation for the Stripe plugin shows this server-side function: `const subscriptions = await auth.api.listActiveSubscriptions({ query: { referenceId: '123',...
Solution:
It is working now. I think the issue was that I needed to add subscription plans to my better auth server configuration. Thanks-