From 543635e3652a5fbe048f7e291a0f84800a669bd4 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sun, 1 Jan 2023 02:54:19 +0100 Subject: [PATCH] Fixed a bug in the link route --- server/routes/link.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/server/routes/link.js b/server/routes/link.js index 660b4ef..2fd0562 100644 --- a/server/routes/link.js +++ b/server/routes/link.js @@ -70,10 +70,9 @@ app.patch("/:id", async (req, res) => { } if (req.body.accessId || req.body.domainName) { - const accessId = req.body.accessId || currentLink.accessId; - const domainName = req.body.domainName || currentLink.domainName; + const link = await getLinkByAccess(req.body.accessId || currentLink.accessId, req.body.domainName || currentLink.domainName); - if (await getLinkByAccess(accessId, domainName)) return res.status(409).json({message: "The provided access id already exists"}); + if (link && link.id !== currentLink.id) return res.status(409).json({message: "The provided access id already exists"}); } await editLink(req.params.id, req.body);