From b1ea5ae80613c01af4ab3efbf045b84e3488fa02 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Tue, 23 Aug 2022 15:11:19 +0300 Subject: [PATCH] fix: remove old keys before inserting new ones --- api/functions/login/login.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/api/functions/login/login.js b/api/functions/login/login.js index 698c0bb..e5b4b0c 100644 --- a/api/functions/login/login.js +++ b/api/functions/login/login.js @@ -37,19 +37,19 @@ const loginHandler = async (req, res) => { if (existingKeys.length >= 3) return res.status(400).json({ status: 'ERROR', reason: "Can only link up to 3 wallets" }) - if (!existingKeys.includes(key)) - await prisma.userKey.create({ - data: { - key, - user_id, - } - }); - // Remove old linking for this key if existing await prisma.userKey.deleteMany({ where: { key } }) + await prisma.userKey.create({ + data: { + key, + user_id, + } + }); + + return res .status(200) .json({ status: "OK" })