mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-07 20:37:44 +00:00
chore: add .env.exmaple on examples
This commit is contained in:
@@ -1,37 +1,45 @@
|
||||
import { betterAuth } from "better-auth";
|
||||
import { organization, passkey, twoFactor } from "better-auth/plugins";
|
||||
import {
|
||||
bearer,
|
||||
organization,
|
||||
passkey,
|
||||
twoFactor,
|
||||
admin,
|
||||
} from "better-auth/plugins";
|
||||
import { reactInvitationEmail } from "./email/invitation";
|
||||
import { LibsqlDialect } from "@libsql/kysely-libsql";
|
||||
import { reactResetPasswordEmail } from "./email/rest-password";
|
||||
import { resend } from "./email/resend";
|
||||
|
||||
const from = process.env.BETTER_AUTH_EMAIL || "delivered@resend.dev";
|
||||
const to = process.env.TEST_EMAIL || "";
|
||||
|
||||
const libsql = new LibsqlDialect({
|
||||
url: process.env.TURSO_DATABASE_URL || "",
|
||||
authToken: process.env.TURSO_AUTH_TOKEN || "",
|
||||
});
|
||||
|
||||
export const auth = betterAuth({
|
||||
database: {
|
||||
provider: "sqlite",
|
||||
url: "./db.sqlite",
|
||||
dialect: libsql,
|
||||
type: "sqlite",
|
||||
},
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
async sendResetPassword(token, user) {
|
||||
const res = await resend.emails.send({
|
||||
async sendResetPassword(url, user) {
|
||||
await resend.emails.send({
|
||||
from,
|
||||
to: user.email,
|
||||
subject: "Reset your password",
|
||||
react: reactResetPasswordEmail({
|
||||
username: user.email,
|
||||
resetLink: `${
|
||||
process.env.NODE_ENV === "development"
|
||||
? "http://localhost:3000"
|
||||
: process.env.NEXT_PUBLIC_APP_URL ||
|
||||
process.env.VERCEL_URL ||
|
||||
process.env.BETTER_AUTH_URL
|
||||
}/reset-password/${token}`,
|
||||
resetLink: url,
|
||||
}),
|
||||
});
|
||||
},
|
||||
sendEmailVerificationOnSignUp: true,
|
||||
async sendVerificationEmail(email, url) {
|
||||
console.log("Sending verification email to", email);
|
||||
const res = await resend.emails.send({
|
||||
from,
|
||||
to: to || email,
|
||||
@@ -68,12 +76,19 @@ export const auth = betterAuth({
|
||||
}),
|
||||
twoFactor({
|
||||
otpOptions: {
|
||||
sendOTP(user, otp) {
|
||||
console.log({ otp });
|
||||
async sendOTP(user, otp) {
|
||||
await resend.emails.send({
|
||||
from,
|
||||
to: user.email,
|
||||
subject: "Your OTP",
|
||||
html: `Your OTP is ${otp}`,
|
||||
});
|
||||
},
|
||||
},
|
||||
}),
|
||||
passkey(),
|
||||
bearer(),
|
||||
admin(),
|
||||
],
|
||||
socialProviders: {
|
||||
github: {
|
||||
@@ -84,5 +99,13 @@ export const auth = betterAuth({
|
||||
clientId: process.env.GOOGLE_CLIENT_ID || "",
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
|
||||
},
|
||||
discord: {
|
||||
clientId: process.env.DISCORD_CLIENT_ID || "",
|
||||
clientSecret: process.env.DISCORD_CLIENT_SECRET || "",
|
||||
},
|
||||
microsoft: {
|
||||
clientId: process.env.MICROSOFT_CLIENT_ID || "",
|
||||
clientSecret: process.env.MICROSOFT_CLIENT_SECRET || "",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user