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:
@@ -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),
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user