mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat(auth): improve email verification and invitation link generation for cloud environment
This commit is contained in:
@@ -29,14 +29,15 @@ const { handler, api } = betterAuth({
|
|||||||
sendOnSignUp: true,
|
sendOnSignUp: true,
|
||||||
autoSignInAfterVerification: true,
|
autoSignInAfterVerification: true,
|
||||||
sendVerificationEmail: async ({ user, url }) => {
|
sendVerificationEmail: async ({ user, url }) => {
|
||||||
console.log("Sending verification email to", user.email);
|
if (IS_CLOUD) {
|
||||||
await sendEmail({
|
await sendEmail({
|
||||||
email: user.email,
|
email: user.email,
|
||||||
subject: "Verify your email",
|
subject: "Verify your email",
|
||||||
text: `
|
text: `
|
||||||
<p>Click the link to verify your email: <a href="${url}">Verify Email</a></p>
|
<p>Click the link to verify your email: <a href="${url}">Verify Email</a></p>
|
||||||
`,
|
`,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
emailAndPassword: {
|
emailAndPassword: {
|
||||||
@@ -137,9 +138,11 @@ const { handler, api } = betterAuth({
|
|||||||
organization({
|
organization({
|
||||||
async sendInvitationEmail(data, _request) {
|
async sendInvitationEmail(data, _request) {
|
||||||
if (IS_CLOUD) {
|
if (IS_CLOUD) {
|
||||||
const inviteLink = `http://localhost:3000/invitation?token=${data.id}`;
|
const host =
|
||||||
|
process.env.NODE_ENV === "development"
|
||||||
console.log("Invitation link", inviteLink);
|
? "http://localhost:3000"
|
||||||
|
: "https://dokploy.com";
|
||||||
|
const inviteLink = `${host}/invitation?token=${data.id}`;
|
||||||
|
|
||||||
await sendEmail({
|
await sendEmail({
|
||||||
email: data.email,
|
email: data.email,
|
||||||
|
|||||||
Reference in New Issue
Block a user