Better Auth

BA

Better Auth

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

Join

bug-reports

help

Duplicate Stripe customer

Hello! I'm using the Stripe plugin with Drizzle and Astro, everything works fine except that the Stripe customer is created twice: - One customer gets created when on sign up - One customer gets created when calling the subscription.update function to redirect to Stripe for the payment Did anybody experience the same problem? Thanks in advance...

Admin not authorized

I am trying to list users with the admin plugin but even when my users only role is "admin" I get a 401 from the endpoint. What could I be missing?
Solution:
I fixed it. I had the role imported as a different name because the plugin is named admin. I renamed the plugin import and it started working.

Add a new role to organization without read permissions

I want to add the role "customer" without any permissions to organization. So when the user calls listOrganizations the org doesnt show up
Solution:
There isn't a built-in way to do this, but I'm pretty sure you can do this by using hooks. Just check if the path is matching the list organization path, then check if there is a session on the request, if so, check if their role is customer to throw an APIError. This is just an example.

how to redirect to previous page after login

example: try to go /dashboard -> middleware intercepted -> redirect to /login -> login success -> redirect to /dashboard

how i implement better auth for microservice

hi there . can i implement better auth for microservice, many of blog out there are taking about jwt for this situation. if you have another ways to this please let me know. thanks for any help

OAuth recreates new accounts each login

In prod (Local works fine), it will create a new user and account each time I remake a new account. here's my auth object: https://paste.learnspigot.com/esabayojoy.typescript

Magic Link email validation and error handling

I've followed the docs on how to implement magic link, however i feel there is a few things missing from the example, email validation and error handling. Can someone please guide me in the right direction with the syntax and or structure of how to implement this? ``` const [email, setEmail] = useState("")...
Solution:
I figured out how to pull errors: const {error} = await authClient.signIn.magicLink({ and validation can be done before calling signIn.magicLink...

How to useSession with cross sub domain cookies enabled

I would like to get the user's session on the client. How can i achieve this ? With my current implementation it doesnt return the session...

Missing valid authorization header

When using the Twitter provider, the error "Missing valid authorization header" appears. Is there any configuration missing? Version: 1.2.9...
No description

authClient.organization.setActive() returns all the members of the organization

Hi, when I call authClient.organization.setActive(), I'm getting a response with a fully-populated members property that lists every member of that organization, including their email addresses. Is that intended? Seems like if I am just trying to sign the user into a tenant, there's no reason necessarily to respond with a list of hundreds or thousands of users?

Changing user's id data type

Is it okay to use uuid as the data type for user's id? Does it have to be text? Will that cause any problems down the line? ```export const user = pgTable("user", { id: uuid("id").primaryKey(),...

Expo Apple Signup on Local Development

I followed the documentation of the expo plugin and the apple plugin. But I am getting a very unhelpful error message from apple saying: Sign up not completed" without any additional error logging anywhere. Does anyone have experience with how to debug this? I get 0 information on what could be going wrong. I am using monorepo with nextjs backend. I already confirmed email signup is working correctly. I get this data from the initial onSuccess when I call the social.signIn endpoint: https://appleid.apple.com/auth/authorize?response_type=code+id_token&client_id=services.ample.app.dev&state=[my-state-here-not]&scope=email+name&redirect_uri=http%3A%2F%2F192.168.0.55%3A3000%2Fapi%2Fauth%2Fcallback%2Fapple&response_mode=form_post...

How to set cookie in Express?

I am trying to use the better-auth api methods, I followed the docs and I did everything that was mentioned, but everytime I try to sign-in or sign-up, I find that the cookies are missing, I will share with you the code I have in case I made a mistake and I am not conscious of it: ``` // handlers.ts import type { Response } from "express"; import type { SignInRequest, SignUpRequest } from "./request-types";...

Full Page Reload After Forgot Password When Using redirectTo Package: @daveyplate/better-auth-ui Ver

When using redirectTo={domain} with React Router and the built-in forgot-password flow, a full page reload is triggered after submitting the form and the email is sent. This causes an unwanted reload (flicker) and breaks client-side navigation. Expected Behavior...

Help me setting up better auth with drizzle

I'm setting up better-auth with drizzle. I set up all the files needed to configure the db. I also ran generate command and it generated auth-schema.ts. So here are my questions: 1. Can I move what's inside auth-schema.ts to db/schema.ts to keep all schemas in one place (just like what's shown in Drizzle's documentation)? 2. After that, can I simply run npx drizzle-kit push to generate the tables in the database?...
Solution:
Yes

How can I trigger a rebuild of BA's generated types?

For some reason BA has lost its typings after I updated some of my packages (including BA) and now the stripe specific types are missing. IDE keeps telling me that stripe functions like the upgradeSubscription or listActiveSubscriptions do not exist, but the app works perfectly fine. Is there a way to trigger BA's type generation? Couldn't find anything about it in the cli docs.
No description

How to change microsoft authorityUrl?

Is there a way to change the authorityUrl for microsoft to 'https://login.microsoftonline.com/common' instead of 'https://login.microsoftonline.com/<tenant-id>'? I can't seem to find anything in the docs. I'm trying to enable authentication for personal accounts....

How to access the full custom session in a middleware?

Hi! I’m trying to access my full custom session inside a middleware, but it seems like getCookieCache() doesn’t return my custom session data. Currently, I’m calling betterFetch('/api/auth/get-session') from the middleware as a workaround, but I’m wondering if there’s a better or more efficient way to directly access the complete session (including custom fields) within middleware? Any tips or best practices would be greatly appreciated. Thanks in advance!...

Custom runtime scope for microsoft provider

Hi, im having trouble requesting additional scopes when signing a user in specifically using microsoft, my auth is configured like this ``` socialProviders: { microsoft: { clientId: process.env.MICROSOFT_CLIENT_ID || "",...
Solution:
No description