04b7c41abf
refactor(prisma): update User model to include banned status and ban details refactor(prisma): modify Account model to include new authentication fields refactor(prisma): enhance Session model with impersonation tracking refactor(prisma): adjust Verification model to include value field feat(auth): integrate admin plugin and enhance email verification process refactor(category): enforce ownership checks in category service methods refactor(item): update item service to validate category ownership feat(item): add ability to fetch items by category refactor(restaurant): implement ownership checks and admin routes in restaurant controller fix(user): restrict user access to admin routes feat(exception): implement global exception filter for consistent error handling
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { betterAuth } from 'better-auth';
|
|
import { prismaAdapter } from 'better-auth/adapters/prisma';
|
|
import { PrismaClient } from '@prisma/client';
|
|
import { admin } from 'better-auth/plugins';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
export const auth = betterAuth({
|
|
database: prismaAdapter(prisma, {
|
|
provider: 'postgresql',
|
|
}),
|
|
plugins: [admin()],
|
|
emailAndPassword: {
|
|
enabled: true,
|
|
requireEmailVerification: true,
|
|
sendResetPassword: async ({ user, token }) => {
|
|
console.log(`Send reset password email to ${user.email}: ${token}`);
|
|
},
|
|
},
|
|
emailVerification: {
|
|
sendVerificationEmail: async ({ user, token }) => {
|
|
console.log(`Send verification email to ${user.email}: ${token}`);
|
|
},
|
|
sendOnSignIn: true,
|
|
autoSignInAfterVerification: true,
|
|
},
|
|
trustedOrigins: ['http://localhost:5173', 'http://localhost:5174'],
|
|
socialProviders: {
|
|
google: {
|
|
prompt: 'select_account',
|
|
clientId: process.env.GOOGLE_CLIENT_ID!,
|
|
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
|
},
|
|
},
|
|
});
|