Skip to content

Commit

Permalink
revert(session): remove OLDEST excees session instead of newest
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksasiriski committed Dec 29, 2024
1 parent 69793ed commit e1a5c0b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/server/db/session.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { and, eq, notInArray } from 'drizzle-orm';
import { and, desc, eq, notInArray } from 'drizzle-orm';
import { encodeBase32LowerCaseNoPadding, encodeHexLowerCase } from '@oslojs/encoding';
import { sha256 } from '@oslojs/crypto/sha2';
import { userTable, type User } from './schema/user';
Expand Down Expand Up @@ -112,7 +112,7 @@ export async function invalidateExcessSessions(userId: number): Promise<void> {
})
.from(sessionTable)
.where(eq(sessionTable.userId, userId))
.orderBy(sessionTable.timestamp)
.orderBy(desc(sessionTable.timestamp))
.limit(maxActiveSessions);

const sessionIdsToKeep = newestSessions.map((session) => session.id);
Expand Down

0 comments on commit e1a5c0b

Please sign in to comment.