diff --git a/src/prisma.ts b/src/prisma.ts index 66f2d50..319b2f4 100644 --- a/src/prisma.ts +++ b/src/prisma.ts @@ -43,8 +43,27 @@ async function refreshDiscordTokens() { } } +async function expireTickets() { + const expired = await prisma.authTicket.findMany({ + where: { + expiresAt: { + lte: new Date() + } + } + }); + + for (const ticket of expired) { + await prisma.authTicket.delete({ + where: { + id: ticket.id + } + }); + } +} + setInterval(async () => { await refreshDiscordTokens(); + await expireTickets(); }, 60 * 1000); export default prisma;