mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-06 12:27:44 +00:00
fix: a bunch of fixes
This commit is contained in:
@@ -2,17 +2,38 @@ import { betterAuth } from "better-auth";
|
||||
import { organization, passkey, twoFactor } from "better-auth/plugins";
|
||||
import { Resend } from "resend";
|
||||
import { reactInvitationEmail } from "./email/invitation";
|
||||
import { LibsqlDialect } from "@libsql/kysely-libsql";
|
||||
import { github, google } from "better-auth/social-providers";
|
||||
import { reactResetPasswordEmail } from "./email/rest-password";
|
||||
|
||||
const resend = new Resend(process.env.RESEND_API_KEY);
|
||||
const from = process.env.BETTER_AUTH_EMAIL || "delivered@resend.dev";
|
||||
|
||||
export const auth = betterAuth({
|
||||
database: {
|
||||
provider: "sqlite",
|
||||
url: "./auth.db",
|
||||
},
|
||||
database: new LibsqlDialect({
|
||||
url: process.env.TURSO_DATABASE_URL || "",
|
||||
authToken: process.env.TURSO_AUTH_TOKEN || "",
|
||||
}),
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
async sendResetPasswordToken(token, user) {
|
||||
const res = 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}`,
|
||||
}),
|
||||
});
|
||||
console.log(res, user.email);
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
organization({
|
||||
@@ -39,9 +60,25 @@ export const auth = betterAuth({
|
||||
console.log(res, data.email);
|
||||
},
|
||||
}),
|
||||
twoFactor(),
|
||||
twoFactor({
|
||||
otpOptions: {
|
||||
sendOTP(user, otp) {
|
||||
console.log({ otp });
|
||||
},
|
||||
},
|
||||
}),
|
||||
passkey({
|
||||
rpID: "localhost",
|
||||
}),
|
||||
],
|
||||
socialProvider: [
|
||||
github({
|
||||
clientId: process.env.GITHUB_CLIENT_ID || "",
|
||||
clientSecret: process.env.GITHUB_CLIENT_SECRET || "",
|
||||
}),
|
||||
google({
|
||||
clientId: process.env.GOOGLE_CLIENT_ID || "",
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user