From 28eadcc1ffbe9198c9d92e48240c77fea79af535 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Tue, 9 Aug 2022 14:25:17 +0300 Subject: [PATCH] fix: remove old userKeys when linking key --- api/functions/login/login.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/functions/login/login.js b/api/functions/login/login.js index 7dcdbf2..cf731e9 100644 --- a/api/functions/login/login.js +++ b/api/functions/login/login.js @@ -39,7 +39,12 @@ const loginHandler = async (req, res) => { return res.status(400).json({ status: 'ERROR', reason: "Can only link up to 3 wallets" }) if (existingKeys.includes(key)) - return res.status(400).json({ status: 'ERROR', reason: "Wallet already linked" }) + return res.status(400).json({ status: 'ERROR', reason: "Wallet already linked" }); + + // Remove old linking for this key if existing + await prisma.userKey.delete({ + where: { key } + }) await prisma.userKey.create({