diff --git a/middleware/registerMW.js b/middleware/registerMW.js index 11875bec0808fa9cbdd63b81a6b0eb936707e740..4f08c110fce5fb082a481d5f8b4f2bae4c895614 100644 --- a/middleware/registerMW.js +++ b/middleware/registerMW.js @@ -43,6 +43,15 @@ module.exports = function () { return; } + if (!('tokenseed' in req.query)) { + res.locals.statuscode = 400; + res.locals.answer = { message: "Also provide token seed." }; + next(); + return; + } + + const tokenSeed = req.query.tokenseed + return db.domainExists(domain).then((exists) => { if (exists) { res.locals.statuscode = 400; @@ -50,7 +59,7 @@ module.exports = function () { next(); return; } else { - const token = md5(domain + randomInt(2 ** 31 - 1) + randomInt(2 ** 31 - 1)).toString('hex'); + const token = md5(domain + tokenSeed).toString('hex'); return db.registerDomain(domain, token) .catch(() => { res.locals.statuscode = 500;