emailVerification: {
autoSignInAfterVerification: true,
sendVerificationEmail: async ( { user, url } ) => {
try {
const verLink = url.replace(/callbackURL=\/$/, "callbackURL=/login");
await sendMail({
email: "info@redacted.be",
sendTo: user.email,
subject: "Account verificatie",
text: "",
html: await render(
reactEmailVerification({
username: user.name,
verificationLink: verLink
})
)
});
console.log("Verification email sent successfully.");
} catch (error) {
console.error("Error sending verification email:", error);
}
}
},
plugins: [
twoFactor({
otpOptions: {
async sendOTP({ user, otp }) {
try {
await sendMail({
email: "info@redacted.be",
sendTo: user.email,
subject: "OTP Code",
text: "",
html: await render(
reactOtpEmail({
username: user.name,
otpCode: otp
})
)
});
} catch (error) {
console.error("Error sending OTP email:", error);
}
}
}
}),
organization({
ac: ac,
roles: {
admin,
member,
machinist,
conducteur,
ploegbaas,
truckdriver,
groundworker,
paver
},
async sendInvitationEmail(data) {
try {
const inviteLink = `https://redacted.be/accept-invitation/${data.id}`;
await sendMail({
email: "info@redacted.be",
sendTo: data.email,
subject: `Invitatie redacted${data.organization.name}`,
text: "",
html: await render(
reactInvitationEmail({
username: data.email,
invitedByUsername: data.inviter.user.name,
invitedByEmail: data.inviter.user.email,
teamName: data.organization.name,
inviteLink: inviteLink,
teamImage: data.organization.logo || "",
})
)
});
} catch (error) {
console.error("Error sending invitation email:", error);
}
},
})
]
});