weepa_ho3
weepa_ho3
BABetter Auth
Created by weepa_ho3 on 3/3/2025 in #help
Typescript error after upgrade to v1.2.1
No description
13 replies
BABetter Auth
Created by weepa_ho3 on 2/4/2025 in #help
Update active organization after creation
When a new organization is created, the active organization is updated in the database, but it is not refetched on the client. Is this the intended behavior? Is there a way to trigger the refetch?
6 replies
BABetter Auth
Created by weepa_ho3 on 2/4/2025 in #help
Type error: Property 'getFullOrganization' does not exist on type 'InferAPI
I added the organization plugin to my auth.ts and to the client. On the client, it works perfectly, and on the server as well, but I can't make a request on the server without getting a type error.
Type error: Property 'getFullOrganization' does not exist on type 'InferAPI<{ ok: { <C extends [(better_call.Context<"/ok", { method: "GET"; metadata: { openapi: { description: string; responses: { "200": { description: string; content: { "application/json": { schema: { type: "object"; properties: { ok: { type: string; }; }; }; }; }; }; }; }; isAction: false; }; }> | undefined)?]>(...'.
Type error: Property 'getFullOrganization' does not exist on type 'InferAPI<{ ok: { <C extends [(better_call.Context<"/ok", { method: "GET"; metadata: { openapi: { description: string; responses: { "200": { description: string; content: { "application/json": { schema: { type: "object"; properties: { ok: { type: string; }; }; }; }; }; }; }; }; isAction: false; }; }> | undefined)?]>(...'.
` in my auth.ts:
import { betterAuth } from 'better-auth';
import { drizzleAdapter } from 'better-auth/adapters/drizzle';
import {
organization,
twoFactor,
} from 'better-auth/plugins';

type AuthReturnType = ReturnType<typeof betterAuth>;

export const auth: AuthReturnType = betterAuth({
databaseHooks: {
user: {
create: {
after: async (user) => {
await createDefaultOrganization({ user });
},
},
},
session: {
create: {
before: async (session) => {
const org = await getDefaultOrganization(session.userId);
return {
data: {
...session,
activeOrganizationId: org?.id,
},
};
},
},
},
},
appName: process.env.APP_NAME,
plugins: [
organization(),
twoFactor(...),

],
});
import { betterAuth } from 'better-auth';
import { drizzleAdapter } from 'better-auth/adapters/drizzle';
import {
organization,
twoFactor,
} from 'better-auth/plugins';

type AuthReturnType = ReturnType<typeof betterAuth>;

export const auth: AuthReturnType = betterAuth({
databaseHooks: {
user: {
create: {
after: async (user) => {
await createDefaultOrganization({ user });
},
},
},
session: {
create: {
before: async (session) => {
const org = await getDefaultOrganization(session.userId);
return {
data: {
...session,
activeOrganizationId: org?.id,
},
};
},
},
},
},
appName: process.env.APP_NAME,
plugins: [
organization(),
twoFactor(...),

],
});
` in my layout:
const initialActiveOrganization = await auth.api.getFullOrganization({
headers: await headers(),
});
const initialActiveOrganization = await auth.api.getFullOrganization({
headers: await headers(),
});
` any idea?
4 replies