From 1a6fee18f21560b8854bc037cc2997f13d8bace5 Mon Sep 17 00:00:00 2001 From: Jeffrey Carl Faden Date: Fri, 28 Apr 2023 12:56:22 -0700 Subject: [PATCH] Require email on invitation post --- src/middlewares/invitation.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/middlewares/invitation.js b/src/middlewares/invitation.js index c9015f51b..5f5300594 100644 --- a/src/middlewares/invitation.js +++ b/src/middlewares/invitation.js @@ -72,6 +72,13 @@ Add them here: ${generateUrl(req, bsHost, `/users/new?email=${querystring.escape const { email } = req.body; try { + if (!email) { + req.flash('error', 'Email is required.'); + return req.session.save(() => { + res.redirect('/invitation/new'); + }); + } + const existingInvitation = await Invitation.findOne({ where: { email } }); if (existingInvitation) {