fix: Welcome emails should not be sent when inviting a user (#2132)

* chore: Bump nodemailer

* fix: Welcome email sent to invites

* test: Add regression test for emails from accountProvisioner
This commit is contained in:
Tom Moor
2021-05-11 18:59:31 -07:00
committed by GitHub
parent 456a7e497b
commit 2cb0bab82a
7 changed files with 27 additions and 12 deletions

View File

@ -3,7 +3,7 @@ import subMinutes from "date-fns/sub_minutes";
import Router from "koa-router";
import { find } from "lodash";
import { AuthorizationError } from "../../errors";
import mailer from "../../mailer";
import mailer, { sendEmail } from "../../mailer";
import methodOverride from "../../middlewares/methodOverride";
import validation from "../../middlewares/validation";
import { User, Team } from "../../models";
@ -97,6 +97,9 @@ router.get("email.callback", async (ctx) => {
if (user.isSuspended) {
return ctx.redirect("/?notice=suspended");
}
if (user.isInvited) {
sendEmail("welcome", user.email, { teamUrl: user.team.url });
}
await user.update({ lastActiveAt: new Date() });