From 4774925eec97ffe432a292f352a6ff697178b4ee Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Fri, 11 Oct 2024 14:52:22 -0400 Subject: [PATCH] Send an email when an educator account is created. --- src/server.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/server.ts b/src/server.ts index fb417f2..90e62f7 100644 --- a/src/server.ts +++ b/src/server.ts @@ -70,6 +70,7 @@ import * as Either from "effect/Either"; import { setupApp } from "./app"; import { getAPIKey } from "./authorization"; import { Sequelize } from "sequelize"; +import { sendEmail } from "./email"; // TODO: Clean up these type definitions @@ -144,10 +145,24 @@ export function createApp(db: Sequelize): Express { result = SignUpResult.BadRequest; } const statusCode = SignUpResult.statusCode(result); + const success = SignUpResult.success(result); + + if (success) { + sendEmail({ + to: "cosmicds@cfa.harvard.edu", + subject: "Educator account created", + text: ` + Educator account created at ${Date()}: + Name: ${data.first_name} ${data.last_name} + Email: ${data.email} + `, + }) + .catch(error => console.log(error)); + } res.status(statusCode).json({ educator_info: data, status: result, - success: SignUpResult.success(result) + success, }); });