additionalField type json not included in type

I have an issue with the additional field features not being added to my user type when it is set as type json. group which is of type stringis included, so is featuresif typed as string. Am I missing something here?
// server setup
export const auth = betterAuth({
database: new Database("..."),
emailAndPassword: {
enabled: true,
autoSignIn: true,
},
basePath: "/xhr/auth",
trustedOrigins: ["http://localhost:3002", "http://localhost:3003"],
user: {
additionalFields: {
features: {
type: "json",
input: false,
},
group: {
type: "string",
input: false,
},
},
},
plugins: [
username(),
localLoginPlugin({ enforceYamlUsersOnly: true, synthEmailDomain: "local" }),
],
});

export type Session = typeof auth.$Infer.Session;

// client setup
export const authClient = createAuthClient({
baseURL: "http://localhost:3002/xhr/auth",
plugins: [
inferAdditionalFields({
user: {
features: {
type: "json",
input: false,
},
group: {
type: "string",
input: false,
},
},
}),
localSignIn(),
],
});

// session.user type
(property) user: {
id: string;
createdAt: Date;
updatedAt: Date;
email: string;
emailVerified: boolean;
name: string;
image?: string | null | undefined;
group: string;
username?: string | null | undefined;
displayUsername?: string | null | undefined;
} | undefined
// server setup
export const auth = betterAuth({
database: new Database("..."),
emailAndPassword: {
enabled: true,
autoSignIn: true,
},
basePath: "/xhr/auth",
trustedOrigins: ["http://localhost:3002", "http://localhost:3003"],
user: {
additionalFields: {
features: {
type: "json",
input: false,
},
group: {
type: "string",
input: false,
},
},
},
plugins: [
username(),
localLoginPlugin({ enforceYamlUsersOnly: true, synthEmailDomain: "local" }),
],
});

export type Session = typeof auth.$Infer.Session;

// client setup
export const authClient = createAuthClient({
baseURL: "http://localhost:3002/xhr/auth",
plugins: [
inferAdditionalFields({
user: {
features: {
type: "json",
input: false,
},
group: {
type: "string",
input: false,
},
},
}),
localSignIn(),
],
});

// session.user type
(property) user: {
id: string;
createdAt: Date;
updatedAt: Date;
email: string;
emailVerified: boolean;
name: string;
image?: string | null | undefined;
group: string;
username?: string | null | undefined;
displayUsername?: string | null | undefined;
} | undefined
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?