Skip to content

Commit

Permalink
Send an email when an educator account is created.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Oct 11, 2024
1 parent 8cf24a1 commit 4774925
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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: "[email protected]",
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,
});
});

Expand Down

0 comments on commit 4774925

Please sign in to comment.