clean up expiring auth tickets
This commit is contained in:
parent
2756694ac6
commit
e01278e050
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue