Skip to content

Commit

Permalink
feat: auto delete old sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
rharkor committed Jul 24, 2023
1 parent f2b3353 commit 236ea07
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/lib/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ export const nextAuthOptions: NextAuthOptions = {
},
})

//* Remove old sessions
const { count } = await prisma.session.deleteMany({
where: {
userId: user.id,
expires: {
lt: new Date(),
},
},
})
logger.debug("Deleted old sessions", count)

logger.debug("User logged in", user.id)
return {
id: user.id.toString(),
Expand Down

0 comments on commit 236ea07

Please sign in to comment.