1
0
Fork 0

clean up expiring auth tickets

This commit is contained in:
Julian 2023-04-25 20:03:36 -04:00
parent 2756694ac6
commit e01278e050
Signed by untrusted user: NotNite
GPG Key ID: BD91A5402CCEB08A
1 changed files with 19 additions and 0 deletions

View File

@ -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 () => { setInterval(async () => {
await refreshDiscordTokens(); await refreshDiscordTokens();
await expireTickets();
}, 60 * 1000); }, 60 * 1000);
export default prisma; export default prisma;