Configure Better Auth to use bcrypt for password hashing

This commit is contained in:
2026-04-07 11:07:47 +05:00
parent c3aefa8a0f
commit 4e6ab6fd2b
+5
View File
@@ -2,6 +2,7 @@ import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { admin } from "better-auth/plugins";
import { prisma } from "./prisma";
import bcrypt from "bcryptjs";
export const auth = betterAuth({
database: prismaAdapter(prisma, {
@@ -10,6 +11,10 @@ export const auth = betterAuth({
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
password: {
hash: (password) => bcrypt.hash(password, 10),
verify: ({ hash, password }) => bcrypt.compare(password, hash),
},
},
plugins: [
admin({