From c7223ea67a918e4cac176dbe836394ff95dda3b4 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Wed, 17 Aug 2022 10:15:28 +0300 Subject: [PATCH] fix: delete old user key --- api/functions/login/login.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/api/functions/login/login.js b/api/functions/login/login.js index 9dda97d..d1dc18b 100644 --- a/api/functions/login/login.js +++ b/api/functions/login/login.js @@ -32,10 +32,8 @@ const loginHandler = async (req, res) => { algorithms: ['HS256'], }) const user_id = payload.user_id; - console.log(user_id); const existingKeys = await prisma.userKey.findMany({ where: { user_id }, select: { key: true } }); - console.log(existingKeys); - console.log(key); + if (existingKeys.length >= 3) return res.status(400).json({ status: 'ERROR', reason: "Can only link up to 3 wallets" }) @@ -43,7 +41,7 @@ const loginHandler = async (req, res) => { return res.status(400).json({ status: 'ERROR', reason: "Wallet already linked" }); // Remove old linking for this key if existing - await prisma.userKey.delete({ + await prisma.userKey.deleteMany({ where: { key } })