mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
🔑 Expand subscriber email validation (#7793)
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
This commit is contained in:
parent
1bc617174d
commit
5e253285bf
1 changed files with 2 additions and 0 deletions
|
@ -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}})
|
||||
|
|
Loading…
Add table
Reference in a new issue