diff --git a/middleware/registerMW.js b/middleware/registerMW.js index f49574131db4c4492d8954553854200e6be8604b..11875bec0808fa9cbdd63b81a6b0eb936707e740 100644 --- a/middleware/registerMW.js +++ b/middleware/registerMW.js @@ -36,7 +36,7 @@ module.exports = function () { const domain = req.query.domain; const format = /^[a-zA-Z0-9\-]*$/; - if (!format.test(domain)) { + if (!format.test(domain) || domain == "") { res.locals.statuscode = 400; res.locals.answer = { message: "Domain name must only contain English letters, numbers and dash (-)." }; next(); diff --git a/middleware/updateMW.js b/middleware/updateMW.js index 68d8debf1464edd50662dcfa54796ce31d7965bd..4f2a16ab280cc903ba6cc9c8d4753b4192ca8b2d 100644 --- a/middleware/updateMW.js +++ b/middleware/updateMW.js @@ -30,6 +30,14 @@ module.exports = function () { const token = req.query.token; const ip = req.query.ip; + const format = /^[0-9.]*$/; + if (!format.test(ip) || ip == "") { + res.locals.statuscode = 400; + res.locals.answer = { message: "Wrong IP format. Should be IPv4." }; + next(); + return; + } + return db.getDomain(token) .catch(() => { res.locals.statuscode = 500;