import { betterAuth } from 'better-auth';
import { prismaAdapter } from "better-auth/adapters/prisma";
import { prisma } from '../../prismdb/prismdb';
export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
trustedOrigins: [`localhost`],
advanced: {
database: { useNumberId: true },
crossSubDomainCookies: {
enabled: true,
domain: "localhost",
},
defaultCookieAttributes: {
secure: true,
httpOnly: true,
sameSite: "none",
partitioned: true,
},
},
emailAndPassword: {
enabled: true,
},
session: {
cookieCache: {
enabled: true,
}
}
});
export async function signUp(email: string, password: string, image: string | null = null) {
const result = await auth.api.signUpEmail({
body: {
name: "User Name",
email,
password,
image,
callbackURL: "/setup"
},
});
return result;
}
export async function signIn(email: string, password: string) {
return await auth.api.signInEmail({
body: {
email,
password,
callbackURL: "/setup"
}
});
}
export async function signOut() {
await auth.api.signOut({
headers: []
});
}
import { betterAuth } from 'better-auth';
import { prismaAdapter } from "better-auth/adapters/prisma";
import { prisma } from '../../prismdb/prismdb';
export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
trustedOrigins: [`localhost`],
advanced: {
database: { useNumberId: true },
crossSubDomainCookies: {
enabled: true,
domain: "localhost",
},
defaultCookieAttributes: {
secure: true,
httpOnly: true,
sameSite: "none",
partitioned: true,
},
},
emailAndPassword: {
enabled: true,
},
session: {
cookieCache: {
enabled: true,
}
}
});
export async function signUp(email: string, password: string, image: string | null = null) {
const result = await auth.api.signUpEmail({
body: {
name: "User Name",
email,
password,
image,
callbackURL: "/setup"
},
});
return result;
}
export async function signIn(email: string, password: string) {
return await auth.api.signInEmail({
body: {
email,
password,
callbackURL: "/setup"
}
});
}
export async function signOut() {
await auth.api.signOut({
headers: []
});
}