summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannik Schönartz2021-06-24 14:56:29 +0200
committerJannik Schönartz2021-06-24 14:56:29 +0200
commit1ea91110da6c862e0dc9f117fc106a18d31b4797 (patch)
tree101a3662af9e881437bd1ca03472763199ff7cfd
parent[server/external-backends/idoit] Small undefined read fix (diff)
downloadbas-1ea91110da6c862e0dc9f117fc106a18d31b4797.tar.gz
bas-1ea91110da6c862e0dc9f117fc106a18d31b4797.tar.xz
bas-1ea91110da6c862e0dc9f117fc106a18d31b4797.zip
[server/registration] For v2 check if client already exists
-rw-r--r--server/api/registration.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/server/api/registration.js b/server/api/registration.js
index fd8b808..8487577 100644
--- a/server/api/registration.js
+++ b/server/api/registration.js
@@ -194,6 +194,13 @@ noAuthRouter.postAsync('/clients', async (req, res) => {
if (req.body.version && req.body.version >= 2) {
/* New hardware collection script */
client = await parseHardwareInformation(req.body)
+
+ // If the client already exists return the configloader ipxe script.
+ const clientDb = await db.client.findOne({ where: { uuid: client.uuid } })
+ if (clientDb) {
+ if (ipxe) return res.send(`#!ipxe\nchain https://` + url + `/api/configloader/\${uuid}`)
+ else return res.send({ error: 'CLIENT_ALREADY_EXISTS', msg: 'A client with the provided UUID does already exist.' })
+ }
} else {
client = req.body.client
if (typeof client === 'string') client = JSON.parse(client)