From 5e253285bf3e8cfa20b4883f7a5a4edbc5f32f39 Mon Sep 17 00:00:00 2001 From: Aileen Nowak Date: Wed, 21 Dec 2016 16:52:47 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=91=20=20Expand=20subscriber=20email?= =?UTF-8?q?=20validation=20(#7793)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue Expand the existing validation for subscriber email to not only check for the existence, but also if it's a valid email address. If it's not a valid email address, it will throw an error. Credits: Eliran Itzhak & Shashank Kumar --- core/server/apps/subscribers/lib/router.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/server/apps/subscribers/lib/router.js b/core/server/apps/subscribers/lib/router.js index ded8281865..c5f1d61612 100644 --- a/core/server/apps/subscribers/lib/router.js +++ b/core/server/apps/subscribers/lib/router.js @@ -78,6 +78,8 @@ function storeSubscriber(req, res, next) { if (_.isEmpty(req.body.email)) { return next(new errors.ValidationError({message: 'Email cannot be blank.'})); + } else if (!validator.isEmail(req.body.email)) { + return next(new errors.ValidationError({message: 'Invalid email.'})); } return api.subscribers.add({subscribers: [req.body]}, {context: {external: true}})