From 1ea91110da6c862e0dc9f117fc106a18d31b4797 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Thu, 24 Jun 2021 12:56:29 +0000 Subject: [server/registration] For v2 check if client already exists --- server/api/registration.js | 7 +++++++ 1 file changed, 7 insertions(+) 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) -- cgit v1.2.3-55-g7522