From 550ac0ab5ea3899b4efe9fed5b905e088466988d Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Wed, 17 Apr 2019 20:44:07 +0000 Subject: [server/registration] If domain gets updated without a hostname, use clientname as hostname --- server/api/registration.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'server/api') diff --git a/server/api/registration.js b/server/api/registration.js index 2ebf522..5c5437b 100644 --- a/server/api/registration.js +++ b/server/api/registration.js @@ -232,9 +232,14 @@ noAuthRouter.postAsync('/clients/:uuid', async (req, res) => { const clientDb = await db.client.findOne({ where: { uuid: req.params.uuid } }) if (!clientDb) return res.status(404).send({ error: 'CLIENT_NOT_FOUND', message: 'There is no client matching the provided uuid.' }) if (client.name) clientDb.update({ name: client.name }) - else client.name = clientDb.name client.id = clientDb.id + // If domain gets updated without a hostname, set the hostname as name. + for (let index in client.networks) { + const network = client.networks[index] + if (network.domain && !network.hostname) network.hostname = clientDb.name + } + if (client && client.system) { // System data. Sometime just string with whitespaces only. if (!/\S/.test(client.system.manufacturer)) client.system.manufacturer = 'unavailable' -- cgit v1.2.3-55-g7522