mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-07 20:37:44 +00:00
chore: fix demo deps
This commit is contained in:
@@ -24,9 +24,22 @@ export const auth = betterAuth({
|
|||||||
dialect: libsql,
|
dialect: libsql,
|
||||||
type: "sqlite",
|
type: "sqlite",
|
||||||
},
|
},
|
||||||
|
emailVerification: {
|
||||||
|
async sendVerificationEmail(user, url) {
|
||||||
|
console.log("Sending verification email to", user.email);
|
||||||
|
const res = await resend.emails.send({
|
||||||
|
from,
|
||||||
|
to: to || user.email,
|
||||||
|
subject: "Verify your email address",
|
||||||
|
html: `<a href="${url}">Verify your email address</a>`,
|
||||||
|
});
|
||||||
|
console.log(res, user.email);
|
||||||
|
},
|
||||||
|
sendEmailVerificationOnSignUp: true,
|
||||||
|
},
|
||||||
emailAndPassword: {
|
emailAndPassword: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
async sendResetPassword(url, user) {
|
async sendResetPassword(user, url) {
|
||||||
await resend.emails.send({
|
await resend.emails.send({
|
||||||
from,
|
from,
|
||||||
to: user.email,
|
to: user.email,
|
||||||
@@ -37,17 +50,6 @@ export const auth = betterAuth({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
sendEmailVerificationOnSignUp: true,
|
|
||||||
async sendVerificationEmail(email, url) {
|
|
||||||
console.log("Sending verification email to", email);
|
|
||||||
const res = await resend.emails.send({
|
|
||||||
from,
|
|
||||||
to: to || email,
|
|
||||||
subject: "Verify your email address",
|
|
||||||
html: `<a href="${url}">Verify your email address</a>`,
|
|
||||||
});
|
|
||||||
console.log(res, email);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
organization({
|
organization({
|
||||||
@@ -89,36 +91,6 @@ export const auth = betterAuth({
|
|||||||
passkey(),
|
passkey(),
|
||||||
bearer(),
|
bearer(),
|
||||||
admin(),
|
admin(),
|
||||||
{
|
|
||||||
id: "last-login-ip",
|
|
||||||
hooks: {
|
|
||||||
after: [
|
|
||||||
{
|
|
||||||
matcher(context) {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
async handler(ctx) {
|
|
||||||
const header = ctx.headers;
|
|
||||||
const response = ctx.context.returned;
|
|
||||||
if (response instanceof Response) {
|
|
||||||
const hasSetCookie = response.headers.get("set-cookie");
|
|
||||||
const hasSessionCookie = response.headers
|
|
||||||
.get("set-cookie")
|
|
||||||
?.includes("session_token");
|
|
||||||
if (hasSessionCookie) {
|
|
||||||
const ipAddress =
|
|
||||||
header?.get("x-forwarded-for") ||
|
|
||||||
header?.get("cf-connecting-ip");
|
|
||||||
if (ipAddress) {
|
|
||||||
//update the user's last login IP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
socialProviders: {
|
socialProviders: {
|
||||||
github: {
|
github: {
|
||||||
|
|||||||
@@ -24,9 +24,22 @@ export const auth = betterAuth({
|
|||||||
dialect: libsql,
|
dialect: libsql,
|
||||||
type: "sqlite",
|
type: "sqlite",
|
||||||
},
|
},
|
||||||
|
emailVerification: {
|
||||||
|
async sendVerificationEmail(user, url) {
|
||||||
|
console.log("Sending verification email to", user.email);
|
||||||
|
const res = await resend.emails.send({
|
||||||
|
from,
|
||||||
|
to: to || user.email,
|
||||||
|
subject: "Verify your email address",
|
||||||
|
html: `<a href="${url}">Verify your email address</a>`,
|
||||||
|
});
|
||||||
|
console.log(res, user.email);
|
||||||
|
},
|
||||||
|
sendEmailVerificationOnSignUp: true,
|
||||||
|
},
|
||||||
emailAndPassword: {
|
emailAndPassword: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
async sendResetPassword(url, user) {
|
async sendResetPassword(user, url) {
|
||||||
await resend.emails.send({
|
await resend.emails.send({
|
||||||
from,
|
from,
|
||||||
to: user.email,
|
to: user.email,
|
||||||
@@ -37,17 +50,6 @@ export const auth = betterAuth({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
sendEmailVerificationOnSignUp: true,
|
|
||||||
async sendVerificationEmail(email, url) {
|
|
||||||
console.log("Sending verification email to", email);
|
|
||||||
const res = await resend.emails.send({
|
|
||||||
from,
|
|
||||||
to: to || email,
|
|
||||||
subject: "Verify your email address",
|
|
||||||
html: `<a href="${url}">Verify your email address</a>`,
|
|
||||||
});
|
|
||||||
console.log(res, email);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
organization({
|
organization({
|
||||||
@@ -107,5 +109,9 @@ export const auth = betterAuth({
|
|||||||
clientId: process.env.MICROSOFT_CLIENT_ID || "",
|
clientId: process.env.MICROSOFT_CLIENT_ID || "",
|
||||||
clientSecret: process.env.MICROSOFT_CLIENT_SECRET || "",
|
clientSecret: process.env.MICROSOFT_CLIENT_SECRET || "",
|
||||||
},
|
},
|
||||||
|
twitch: {
|
||||||
|
clientId: process.env.TWITCH_CLIENT_ID || "",
|
||||||
|
clientSecret: process.env.TWITCH_CLIENT_SECRET || "",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user