Invite members (#161)

* Allow user invitations

* Restyle inviting members

* Remove annoying comment

* Add page for accepting an invitation

* Send invitation email with Brevo

* Prevent admins from removing personal project users

* Mark access ceontrol for cancelProjectInvitation

* Make RadioGroup controlled

* Shorten form helper text

* Use nodemailer to send emails

* Update .env.example
This commit is contained in:
arcticfly
2023-08-16 17:25:31 -07:00
committed by GitHub
parent 0fba2c9ee7
commit 809ef04dc1
19 changed files with 1152 additions and 45 deletions

View File

@@ -0,0 +1,31 @@
import { marked } from "marked";
import nodemailer from "nodemailer";
import { env } from "~/env.mjs";
const transporter = nodemailer.createTransport({
// All the SMTP_ env vars come from https://app.brevo.com/settings/keys/smtp
// @ts-expect-error nodemailer types are wrong
host: env.SMTP_HOST,
port: env.SMTP_PORT,
auth: {
user: env.SMTP_LOGIN,
pass: env.SMTP_PASSWORD,
},
});
export const sendEmail = async (options: { to: string; subject: string; body: string }) => {
const bodyHtml = await marked.parseInline(options.body, { mangle: false });
try {
await transporter.sendMail({
from: env.SENDER_EMAIL,
to: options.to,
subject: options.subject,
html: bodyHtml,
text: options.body,
});
} catch (error) {
console.error("error sending email", error);
throw error;
}
};