mirror of
https://github.com/aljazceru/landscape-template.git
synced 2026-01-21 07:14:29 +01:00
fix: remove old keys before inserting new ones
This commit is contained in:
@@ -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" })
|
||||
|
||||
Reference in New Issue
Block a user