summaryrefslogtreecommitdiffstats
path: root/server/api
diff options
context:
space:
mode:
authorJannik Schönartz2019-04-17 22:44:07 +0200
committerJannik Schönartz2019-04-17 22:44:07 +0200
commit550ac0ab5ea3899b4efe9fed5b905e088466988d (patch)
tree3990ef8247820c2ee18f2d38509360c8ad38e8c8 /server/api
parent[server/external-backends] Fix for the update client mehtod (unnecessary idoi... (diff)
downloadbas-550ac0ab5ea3899b4efe9fed5b905e088466988d.tar.gz
bas-550ac0ab5ea3899b4efe9fed5b905e088466988d.tar.xz
bas-550ac0ab5ea3899b4efe9fed5b905e088466988d.zip
[server/registration] If domain gets updated without a hostname, use clientname as hostname
Diffstat (limited to 'server/api')
-rw-r--r--server/api/registration.js7
1 files changed, 6 insertions, 1 deletions
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'