mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
Better-auth configuration
This commit is contained in:
parent
a02da83781
commit
5d04693a09
9 changed files with 62 additions and 144 deletions
24
src/auth.ts
Normal file
24
src/auth.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { betterAuth } from 'better-auth'
|
||||
import { prismaAdapter } from 'better-auth/adapters/prisma'
|
||||
import { username } from 'better-auth/plugins'
|
||||
|
||||
import prismaClient from './utils/prisma-client'
|
||||
import { sendEmail } from 'utils/email'
|
||||
import forgorTemplate from 'utils/forgorTemplate'
|
||||
|
||||
export const auth = betterAuth({
|
||||
database: prismaAdapter(prismaClient, { provider: 'mysql' }),
|
||||
user: { modelName: 'users' },
|
||||
plugins: [username()],
|
||||
emailVerification: {
|
||||
sendOnSignUp: true,
|
||||
autoSignInAfterVerification: true
|
||||
},
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
requireEmailVerification: true,
|
||||
sendResetPassword: async ({ user, url, token }, request) => {
|
||||
await sendEmail(user.email, 'Reset your password', forgorTemplate.replaceAll('{{forgor_link}}', url))
|
||||
}
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue