fix(backend): session dedupe + mint authority JSON array parsing

1. Auth callback now deletes old sessions before creating new one,
   and adds Date.now() nonce to JWT to prevent unique constraint
   violations on duplicate login attempts.

2. Solana mint authority now accepts both JSON array and base58
   formats for SOLANA_MINT_AUTHORITY_KEYPAIR env var.
This commit is contained in:
2026-04-21 14:26:21 -04:00
parent 5db61212dc
commit 2215eb900b
2 changed files with 195 additions and 177 deletions
+8 -2
View File
@@ -108,11 +108,17 @@ router.post(
});
}
// Create session
// Delete old sessions and create new one
await prisma.session.deleteMany({ where: { userId: user.id } });
const sessionToken = jwt.sign(
{ userId: user.id, nonce: Date.now() },
JWT_SECRET,
{ expiresIn: "7d" },
);
const session = await prisma.session.create({
data: {
userId: user.id,
token: jwt.sign({ userId: user.id }, JWT_SECRET, { expiresIn: "7d" }),
token: sessionToken,
expiresAt: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),
},
});