mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
This commit adds the necessary functionality to confirm a user's account. It includes the addition of a new column in the user table to track whether an account is confirmed or not, and the implementation of JWT for confirmation tokens. This commit integrates the SparkPost API as well as React Email to send dynamic emails for whatever purpose. Upon user registration, a confirmation email will be sent to the user.
26 lines
554 B
TypeScript
26 lines
554 B
TypeScript
import client from './client';
|
|
|
|
interface EmailParams {
|
|
address: string;
|
|
text: string;
|
|
html: string;
|
|
subject: string;
|
|
}
|
|
|
|
const { SPARKPOST_SENDER_ADDRESS } = process.env;
|
|
|
|
if (!SPARKPOST_SENDER_ADDRESS) {
|
|
throw new Error('SPARKPOST_SENDER_ADDRESS env variable is not set.');
|
|
}
|
|
|
|
const sendEmail = async ({ address, text, html, subject }: EmailParams) => {
|
|
const from = SPARKPOST_SENDER_ADDRESS;
|
|
|
|
await client.transmissions.send({
|
|
content: { from, html, subject, text },
|
|
recipients: [{ address }],
|
|
});
|
|
};
|
|
|
|
export default sendEmail;
|