// 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